{"id":22152131,"url":"https://github.com/findinpath/spring-session-redis","last_synced_at":"2026-07-04T17:31:08.809Z","repository":{"id":112791049,"uuid":"270642035","full_name":"findinpath/spring-session-redis","owner":"findinpath","description":"Proof of concept for storing spring session in Redis Master-Replica configuration.","archived":false,"fork":false,"pushed_at":"2024-08-01T21:05:14.000Z","size":15,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-29T08:57:42.804Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/findinpath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-06-08T11:26:30.000Z","updated_at":"2020-06-08T11:41:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"e7be46ad-2e8c-483e-901c-e8c8ef47f677","html_url":"https://github.com/findinpath/spring-session-redis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/findinpath/spring-session-redis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fspring-session-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fspring-session-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fspring-session-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fspring-session-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/findinpath","download_url":"https://codeload.github.com/findinpath/spring-session-redis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fspring-session-redis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35130722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-04T02:00:05.987Z","response_time":113,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-12-02T00:47:20.872Z","updated_at":"2026-07-04T17:31:08.788Z","avatar_url":"https://github.com/findinpath.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Spring Session with Redis persistence\n=====================================\n\nThis project acts as a simple proof of concept on how to do Spring Session \npersistence based on Redis Master-Replica configuration\n\n## Introduction\n\nThe main advantage of persisting the session data in [redis](https://redis.io/)\nis that there's no need to work with sticky session cookies on the load balancer side.\nWhen restarting the spring boot application the session information will not be looked up\nlocally, but instead in redis.\n\nThe code of the project is based on the project\n[spring-session-sample-boot-redis-simple](https://github.com/spring-projects/spring-session/tree/master/spring-session-samples/spring-session-sample-boot-redis-simple)\npresent in the sample project from the [spring-session](https://github.com/spring-projects/spring-session)\nGithub repository.\n\nThis project spawns a Redis Master-Replica environment based on the docker\nimage [bitnami/redis](https://hub.docker.com/r/bitnami/redis/).\n\nThe Redis Master-Replica topic is explained more in detail in the page:\n\nhttps://redis.io/topics/replication\n\nRedis has one master and several following replicas. This means that the **WRITE** operations\nare made **only** on the **master** redis node, but for **READ** operations are preferred on the replica\nredis nodes.  \n\nJust for heads-up information, probably [Redis Sentinel](https://redis.io/topics/sentinel) is also a viable alternative to\n[Redis Static Master-Replica](https://redis.io/topics/replication) configuration. \n\n## Run the project\n\nStart the redis master-replica docker-compose environment\n\n```bash\ndocker-compose -f docker/docker-compose.yml up -d --scale redis-master=1 --scale redis-replica=3\n```\n\nCheck the ports exposed by the redis replica servers:\n\n```\ndocker-compose -f docker/docker-compose.yml ps\n```\n\nand modify accordingly the [application.yml](src/main/resources/application.yml)\nfile to point the slaves to the correct addresses.\n\n\nStart the spring boot application\n\n```bash\nmvn spring-boot:run\n```\n\n\nVisit the page on the browser:\n\nhttp://localhost:8080/\n\n\nand login by using the following credentials:\n\n- username: `user`\n- password: `password`\n\nWhen restarting the spring boot application and reloading the browser page  or \nopening the browser again, the login page shouldn't be shown again and the user\nshould see the secured page.\n\n\nIn case that the content on the redis side needs to be checked\nuse [redis-cli](https://redis.io/topics/rediscli) or any other Redis browser\n\n\n```bash\nredis-cli -p 6379 -a my_redis_password\n```\n\nSome useful redis commands for the purpose of this proof of concept project:\n\n```\n127.0.0.1:6379\u003e keys *\n1) \"spring:session:sessions:5c5c2f89-912c-4537-bdef-61b0d37bb155\"\n127.0.0.1:6379\u003e HGETALL spring:session:sessions:5c5c2f89-912c-4537-bdef-61b0d37bb155\n 1) \"creationTime\"\n 2) \"\\xac\\xed\\x00\\x05sr\\x00\\x0ejava.lang.Long;\\x8b\\xe4\\x90\\xcc\\x8f#\\xdf\\x02\\x00\\x01J\\x00\\x05valuexr\\x00\\\n...\n```\n\n\nStop the redis master-replica docker-compose environment\n\n```bash\ndocker-compose -f docker/docker-compose.yml down\n```\n\n\n## Miscellaneous\n\n\n### Login page\nThe spring security provides by default a login page this is why this project doesn't include one.\nTo see where the login page is generated, consult:\n\nhttps://stackoverflow.com/questions/35557484/where-is-spring-security-default-login-page-code-located/35557596#35557596\n\n### Bitnami Redis docker images\n\nCheck out more details about how to setup replication on the `bitnami/redis` docker image on the page:\n\nhttps://hub.docker.com/r/bitnami/redis/\n\n**NOTE** that working with a volume to store the data for the redis master would allow restarting the master\nand would provide an almost seamless session experience even in case when a restart of the redis master is happening. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffindinpath%2Fspring-session-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffindinpath%2Fspring-session-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffindinpath%2Fspring-session-redis/lists"}