{"id":13714287,"url":"https://github.com/antonlindstrom/pgstore","last_synced_at":"2025-04-15T03:17:08.706Z","repository":{"id":13031293,"uuid":"15710954","full_name":"antonlindstrom/pgstore","owner":"antonlindstrom","description":"A Postgres session store backend for gorilla/sessions","archived":false,"fork":false,"pushed_at":"2024-03-13T14:12:52.000Z","size":50,"stargazers_count":97,"open_issues_count":6,"forks_count":30,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T03:17:04.577Z","etag":null,"topics":["go","gorilla","postgres","sessions","sessionstorage"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonlindstrom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-01-07T17:12:03.000Z","updated_at":"2025-03-27T11:44:46.000Z","dependencies_parsed_at":"2024-06-18T13:38:14.591Z","dependency_job_id":"ac11bb9c-d42f-4fe0-b71f-86edcd388bbb","html_url":"https://github.com/antonlindstrom/pgstore","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonlindstrom%2Fpgstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonlindstrom%2Fpgstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonlindstrom%2Fpgstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonlindstrom%2Fpgstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonlindstrom","download_url":"https://codeload.github.com/antonlindstrom/pgstore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997060,"owners_count":21195799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","gorilla","postgres","sessions","sessionstorage"],"created_at":"2024-08-02T23:01:56.328Z","updated_at":"2025-04-15T03:17:08.687Z","avatar_url":"https://github.com/antonlindstrom.png","language":"Go","funding_links":[],"categories":["Repositories","Go"],"sub_categories":[],"readme":"# pgstore\n\nA session store backend for [gorilla/sessions](http://www.gorillatoolkit.org/pkg/sessions) - [src](https://github.com/gorilla/sessions).\n\n## Installation\n\n    make get-deps\n\n## Documentation\n\nAvailable on [godoc.org](http://www.godoc.org/github.com/antonlindstrom/pgstore).\n\nSee http://www.gorillatoolkit.org/pkg/sessions for full documentation on underlying interface.\n\n### Example\n\n[embedmd]:# (examples/sessions.go)\n```go\npackage examples\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/antonlindstrom/pgstore\"\n)\n\n// ExampleHandler is an example that displays the usage of PGStore.\nfunc ExampleHandler(w http.ResponseWriter, r *http.Request) {\n\t// Fetch new store.\n\tstore, err := pgstore.NewPGStore(\"postgres://user:password@127.0.0.1:5432/database?sslmode=verify-full\", []byte(\"secret-key\"))\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tdefer store.Close()\n\n\t// Run a background goroutine to clean up expired sessions from the database.\n\tdefer store.StopCleanup(store.Cleanup(time.Minute * 5))\n\n\t// Get a session.\n\tsession, err := store.Get(r, \"session-key\")\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\n\t// Add a value.\n\tsession.Values[\"foo\"] = \"bar\"\n\n\t// Save.\n\tif err = session.Save(r, w); err != nil {\n\t\tlog.Fatalf(\"Error saving session: %v\", err)\n\t}\n\n\t// Delete session.\n\tsession.Options.MaxAge = -1\n\tif err = session.Save(r, w); err != nil {\n\t\tlog.Fatalf(\"Error saving session: %v\", err)\n\t}\n}\n```\n\n## Breaking changes\n\n* 2016-07-19 - `NewPGStore` and `NewPGStoreFromPool` now returns `(*PGStore, error)`\n\n## Thanks\n\nI've stolen, borrowed and gotten inspiration from the other backends available:\n\n* [redistore](https://github.com/boj/redistore)\n* [mysqlstore](https://github.com/srinathgs/mysqlstore)\n* [babou dbstore](https://github.com/drbawb/babou/blob/master/lib/session/dbstore.go)\n\nThank you all for sharing your code!\n\nWhat makes this backend different is that it's for PostgreSQL.\n\nWe've recently refactored this backend to use the standard database/sql driver instead of Gorp. This removes a dependency and makes this package very lightweight and makes database interactions very transparent. Lastly, from the standpoint of unit testing where you want to mock the database layer instead of requiring a real database, you can now easily use a package like [go-SQLMock](https://github.com/DATA-DOG/go-sqlmock) to do just that.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonlindstrom%2Fpgstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonlindstrom%2Fpgstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonlindstrom%2Fpgstore/lists"}