{"id":21428349,"url":"https://github.com/ushelp/easyshiro-redis-cache","last_synced_at":"2025-07-14T10:31:57.151Z","repository":{"id":27631045,"uuid":"112734237","full_name":"ushelp/EasyShiro-Redis-Cache","owner":"ushelp","description":"基于 Redis 的 Shrio 缓存，支持 Jedis 直连和  Spring-Data-Redis RedisTemplate。An implement of redis cache can be used by shiro, Support Jedis direct connect and Spring-Data-Redis RedisTemplate.","archived":false,"fork":false,"pushed_at":"2022-10-12T20:05:16.000Z","size":31,"stargazers_count":3,"open_issues_count":5,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T23:01:54.918Z","etag":null,"topics":["easyshiro","easyshiro-redis-cache","redis","redis-cache","redis-shiro","redistemplate","shiro","shiro-redis","shiro-redis-cache","shiro-redis-session","shiro-session"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ushelp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["http://www.easyproject.cn/donation"]}},"created_at":"2017-12-01T11:49:19.000Z","updated_at":"2023-12-22T05:41:16.000Z","dependencies_parsed_at":"2022-08-07T13:00:45.536Z","dependency_job_id":null,"html_url":"https://github.com/ushelp/EasyShiro-Redis-Cache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ushelp/EasyShiro-Redis-Cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushelp%2FEasyShiro-Redis-Cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushelp%2FEasyShiro-Redis-Cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushelp%2FEasyShiro-Redis-Cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushelp%2FEasyShiro-Redis-Cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ushelp","download_url":"https://codeload.github.com/ushelp/EasyShiro-Redis-Cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushelp%2FEasyShiro-Redis-Cache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265280721,"owners_count":23739854,"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":["easyshiro","easyshiro-redis-cache","redis","redis-cache","redis-shiro","redistemplate","shiro","shiro-redis","shiro-redis-cache","shiro-redis-session","shiro-session"],"created_at":"2024-11-22T22:12:49.567Z","updated_at":"2025-07-14T10:31:52.133Z","avatar_url":"https://github.com/ushelp.png","language":"HTML","funding_links":["http://www.easyproject.cn/donation"],"categories":[],"sub_categories":[],"readme":"# EasyShiro-Redis-Cache\n\n\n基于 Redis 的 Shrio 缓存，支持 Jedis 直连和  Spring-Data-Redis RedisTemplate。\n\nAn implement of redis cache can be used by shiro, Support Jedis direct connect and Spring-Data-Redis RedisTemplate.\n\nThanks [shiro-redis](https://github.com/alexxiyang/shiro-redis).\n\n## Featuter\n\n- **中文**\n\n\t1. 支持基于 Jdeis 直接配置 Redis 连接（ `INI`, `XML`）\n\t\n\t2. 支持与 Spring 集成时，使用  Spring-Data-Redis 的 `RedisTemplate` （`XML`）\n\t\n\t3. 支持与 \n[EasyShiro](https://github.com/ushelp/EasyShiro 'EasyShiro') 集成\n\n\n- **English**\n\n\t1. Support direct configuration of Redis connection (`INI`,` XML`)\n\t\n\t2. Support for integration with Spring-Data-Redis RedisTemplate (`XML`)\n\t\n\t3. Support for integration \n[EasyShiro](https://github.com/ushelp/EasyShiro 'EasyShiro')\n\n\n## Maven\n\n```XML\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecn.easyproject\u003c/groupId\u003e\n\t\u003cartifactId\u003eeasyshiro-redis-cache\u003c/artifactId\u003e\n\t\u003cversion\u003e2.6.0-RELEASE\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Configure\n\n\n### RedisManager(Jedis)\n\n- shiro.ini\n\n\t```properties\n\t#redisManager\n\tredisManager = cn.easyproject.shirorediscache.RedisManager\n\t#optional if you don't specify host the default value is 127.0.0.1\n\tredisManager.host = 127.0.0.1\n\t#optional , default value: 6379\n\tredisManager.port = 6379\n\t#optional, timeout for jedis try to connect to redis server(In milliseconds), not equals to expire time! \n\tredisManager.timeout = 0\n\t#optional, password for redis server\n\tredisManager.password = \n\t\n\t#============redisSessionDAO=============\n\tredisSessionDAO = cn.easyproject.shirorediscache.RedisSessionDAO\n\tredisSessionDAO.redisManager = $redisManager\n\t#optional, default value:0, never expire. The expire time is in second\n\tredisSessionDAO.expire = 1800\n\t\n\tsessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager\n\t\n\tsessionManager.sessionDAO = $redisSessionDAO\n\tsecurityManager.sessionManager = $sessionManager\n\t\n\t\n\t#============redisCacheManager===========\n\tcacheManager = cn.easyproject.shirorediscache.RedisCacheManager\n\tcacheManager.redisManager = $redisManager\n\t#custom your redis key prefix, if you doesn't define this parameter shiro-redis will use 'shiro_redis_session:' as default prefix\n\tcacheManager.keyPrefix = users:security:authz:\n\tsecurityManager.cacheManager = $cacheManager\n\t```\n\n- shiro.xml\n\n\t```xml\n\t\u003c!-- shiro filter --\u003e\n\t\u003cbean id=\"ShiroFilter\" class=\"org.apache.shiro.spring.web.ShiroFilterFactoryBean\"\u003e\n\t\t\u003cproperty name=\"securityManager\" ref=\"securityManager\"/\u003e\n\t\t\n\t\t\u003c!--\n\t\t\u003cproperty name=\"loginUrl\" value=\"/login.jsp\"/\u003e\n\t\t\u003cproperty name=\"successUrl\" value=\"/home.jsp\"/\u003e  \n\t\t\u003cproperty name=\"unauthorizedUrl\" value=\"/unauthorized.jsp\"/\u003e\n\t\t--\u003e\n\t\t\u003c!-- The 'filters' property is not necessary since any declared javax.servlet.Filter bean  --\u003e\n\t\t\u003c!-- defined will be automatically acquired and available via its beanName in chain        --\u003e\n\t\t\u003c!-- definitions, but you can perform instance overrides or name aliases here if you like: --\u003e\n\t\t\u003c!-- \u003cproperty name=\"filters\"\u003e\n\t\t\t\u003cutil:map\u003e\n\t\t\t\t\u003centry key=\"anAlias\" value-ref=\"someFilter\"/\u003e\n\t\t\t\u003c/util:map\u003e\n\t\t\u003c/property\u003e --\u003e\n\t\t\u003cproperty name=\"filterChainDefinitions\"\u003e\n\t\t\t\u003cvalue\u003e\n\t\t\t\t/login.jsp = anon\n\t\t\t\t/user/** = anon\n\t\t\t\t/register/** = anon\n\t\t\t\t/unauthorized.jsp = anon\n\t\t\t\t/css/** = anon\n\t\t\t\t/js/** = anon\n\t\t\t\t\n\t\t\t\t/** = authc\n\t\t\t\u003c/value\u003e\n\t\t\u003c/property\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003c!-- shiro securityManager --\u003e\n\t\u003cbean id=\"securityManager\" class=\"org.apache.shiro.web.mgt.DefaultWebSecurityManager\"\u003e\n\t\n\t\t\u003c!-- Single realm app.  If you have multiple realms, use the 'realms' property instead. --\u003e\n\t\t\n\t\t\u003c!-- sessionManager --\u003e\n\t\t\u003cproperty name=\"sessionManager\" ref=\"sessionManager\" /\u003e\n\t\t\n\t\t\u003c!-- cacheManager --\u003e\n\t\t\u003cproperty name=\"cacheManager\" ref=\"cacheManager\" /\u003e\n\t\t\n\t\t\u003c!-- By default the servlet container sessions will be used.  Uncomment this line\n\t\t\t to use shiro's native sessions (see the JavaDoc for more): --\u003e\n\t\t\u003c!-- \u003cproperty name=\"sessionMode\" value=\"native\"/\u003e --\u003e\n\t\u003c/bean\u003e\n\t\u003cbean id=\"lifecycleBeanPostProcessor\" class=\"org.apache.shiro.spring.LifecycleBeanPostProcessor\"/\u003e\t\n\t\n\t\u003c!-- shiro redisManager --\u003e\n\t\u003cbean id=\"redisManager\" class=\"cn.easyproject.shirorediscache.RedisManager\"\u003e\n\t\t\u003cproperty name=\"host\" value=\"127.0.0.1\"/\u003e\n\t\t\u003cproperty name=\"port\" value=\"6379\"/\u003e\n\t\t\u003c!-- optional properties:\n\t\t\u003cproperty name=\"timeout\" value=\"10000\"/\u003e\n\t\t\u003cproperty name=\"password\" value=\"123456\"/\u003e\n\t\t--\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003c!-- redisSessionDAO --\u003e\n\t\u003cbean id=\"redisSessionDAO\" class=\"cn.easyproject.shirorediscache.RedisSessionDAO\"\u003e\n\t\t\u003cproperty name=\"redisManager\" ref=\"redisManager\" /\u003e\n\t\t\u003c!-- optional, default value:0, never expire. The expire time is in second --\u003e\n\t\t\u003cproperty name=\"expire\" value=\"1800\"/\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003c!-- sessionManager --\u003e\n\t\u003cbean id=\"sessionManager\" class=\"org.apache.shiro.web.session.mgt.DefaultWebSessionManager\"\u003e\n\t\t\u003cproperty name=\"sessionDAO\" ref=\"redisSessionDAO\" /\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003c!-- cacheManager --\u003e\n\t\u003cbean id=\"cacheManager\" class=\"cn.easyproject.shirorediscache.RedisCacheManager\"\u003e\n\t\t\u003cproperty name=\"redisManager\" ref=\"redisManager\" /\u003e\n\t\u003c/bean\u003e\n\t```\n\n\n### Spring-Data-Redis RedisTemplate\n\n- shiro.xml\n\n\tRedisTemplate key is must `StringRedisSerializer`.\n\t\n\t```XML\n\t\u003c!-- RedisTemplate Start --\u003e\n\t\u003c!-- JedisPool --\u003e\n\t\u003cbean id=\"jedisPoolConfig\" class=\"redis.clients.jedis.JedisPoolConfig\"\u003e\n\t\t\u003cproperty name=\"maxTotal\" value=\"${redis.pool.maxTotal}\"\u003e\u003c/property\u003e\n\t\t\u003cproperty name=\"maxIdle\" value=\"${redis.pool.maxIdle}\"\u003e\u003c/property\u003e\n\t\t\u003cproperty name=\"maxWaitMillis\" value=\"${redis.pool.maxWaitMillis}\"\u003e\u003c/property\u003e\n\t\t\u003cproperty name=\"testOnBorrow\" value=\"${redis.pool.testOnBorrow}\"\u003e\u003c/property\u003e\n\t\t\u003cproperty name=\"testOnReturn\" value=\"${redis.pool.testOnReturn}\"\u003e\u003c/property\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003cbean id=\"jedisConnFactory\"\n\t\tclass=\"org.springframework.data.redis.connection.jedis.JedisConnectionFactory\"\n\t\tp:use-pool=\"true\"\u003e\n\t\t\u003cproperty name=\"hostName\" value=\"${redis.host}\"\u003e\u003c/property\u003e\n\t\t\u003cproperty name=\"port\" value=\"${redis.port}\"\u003e\u003c/property\u003e\n\t\t\u003cproperty name=\"database\" value=\"${redis.database}\"\u003e\u003c/property\u003e\n\t\t\u003c!-- \u003cproperty name=\"password\" value=\"pwd456\"\u003e\u003c/property\u003e --\u003e\n\t\t\u003cproperty name=\"poolConfig\" ref=\"jedisPoolConfig\"\u003e\u003c/property\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003c!-- Redis template definition --\u003e\n\t\u003cbean id=\"redisTemplate\" class=\"org.springframework.data.redis.core.RedisTemplate\"\n\t\tp:connection-factory-ref=\"jedisConnFactory\"\u003e\n\t\t\n\t\t\u003c!-- !IMPORTANT: key is must 'StringRedisSerializer' --\u003e\n\t\t\u003cproperty name=\"keySerializer\"\u003e\n\t\t\t\u003cbean class=\"org.springframework.data.redis.serializer.StringRedisSerializer\"\u003e\u003c/bean\u003e\n\t\t\u003c/property\u003e\n\t\t\u003cproperty name=\"hashKeySerializer\"\u003e\n\t\t\t\u003cbean class=\"org.springframework.data.redis.serializer.StringRedisSerializer\"\u003e\u003c/bean\u003e\n\t\t\u003c/property\u003e\n\t\t\u003cproperty name=\"valueSerializer\"\u003e\n\t\t\t\u003cbean class=\"org.springframework.data.redis.serializer.JdkSerializationRedisSerializer\"\u003e\u003c/bean\u003e\n\t\t\u003c/property\u003e\n\t\t\u003cproperty name=\"hashValueSerializer\"\u003e\n\t\t\t\u003cbean class=\"org.springframework.data.redis.serializer.JdkSerializationRedisSerializer\"\u003e\u003c/bean\u003e\n\t\t\u003c/property\u003e\n\t\u003c/bean\u003e\n\t\u003c!-- RedisTemplate End--\u003e\n\t\n\t\t\u003c!-- shiro filter --\u003e\n\t\u003cbean id=\"ShiroFilter\" class=\"org.apache.shiro.spring.web.ShiroFilterFactoryBean\"\u003e\n\t\t\u003cproperty name=\"securityManager\" ref=\"securityManager\"/\u003e\n\t\t\n\t\t\u003c!--\n\t\t\u003cproperty name=\"loginUrl\" value=\"/login.jsp\"/\u003e\n\t\t\u003cproperty name=\"successUrl\" value=\"/home.jsp\"/\u003e  \n\t\t\u003cproperty name=\"unauthorizedUrl\" value=\"/unauthorized.jsp\"/\u003e\n\t\t--\u003e\n\t\t\u003c!-- The 'filters' property is not necessary since any declared javax.servlet.Filter bean  --\u003e\n\t\t\u003c!-- defined will be automatically acquired and available via its beanName in chain        --\u003e\n\t\t\u003c!-- definitions, but you can perform instance overrides or name aliases here if you like: --\u003e\n\t\t\u003c!-- \u003cproperty name=\"filters\"\u003e\n\t\t\t\u003cutil:map\u003e\n\t\t\t\t\u003centry key=\"anAlias\" value-ref=\"someFilter\"/\u003e\n\t\t\t\u003c/util:map\u003e\n\t\t\u003c/property\u003e --\u003e\n\t\t\u003cproperty name=\"filterChainDefinitions\"\u003e\n\t\t\t\u003cvalue\u003e\n\t\t\t\t/login.jsp = anon\n\t\t\t\t/user/** = anon\n\t\t\t\t/register/** = anon\n\t\t\t\t/unauthorized.jsp = anon\n\t\t\t\t/css/** = anon\n\t\t\t\t/js/** = anon\n\t\t\t\t\n\t\t\t\t/** = authc\n\t\t\t\u003c/value\u003e\n\t\t\u003c/property\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003c!-- shiro securityManager --\u003e\n\t\u003cbean id=\"securityManager\" class=\"org.apache.shiro.web.mgt.DefaultWebSecurityManager\"\u003e\n\t\n\t\t\u003c!-- Single realm app.  If you have multiple realms, use the 'realms' property instead. --\u003e\n\t\t\n\t\t\u003c!-- sessionManager --\u003e\n\t\t\u003cproperty name=\"sessionManager\" ref=\"sessionManager\" /\u003e\n\t\t\n\t\t\u003c!-- cacheManager --\u003e\n\t\t\u003cproperty name=\"cacheManager\" ref=\"cacheManager\" /\u003e\n\t\t\n\t\t\u003c!-- By default the servlet container sessions will be used.  Uncomment this line\n\t\t\t to use shiro's native sessions (see the JavaDoc for more): --\u003e\n\t\t\u003c!-- \u003cproperty name=\"sessionMode\" value=\"native\"/\u003e --\u003e\n\t\u003c/bean\u003e\n\t\u003cbean id=\"lifecycleBeanPostProcessor\" class=\"org.apache.shiro.spring.LifecycleBeanPostProcessor\"/\u003e\t\n\t\n\t\u003c!-- redisSessionDAO --\u003e\n\t\u003cbean id=\"redisSessionDAO\" class=\"cn.easyproject.shirorediscache.RedisSessionDAO\"\u003e\n\t\t\u003cproperty name=\"redisTemplate\" ref=\"redisTemplate\" /\u003e\n\t\t\u003c!-- optional, default value:0, never expire. The expire time is in second --\u003e\n\t\t\u003cproperty name=\"expire\" value=\"1800\"/\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003c!-- sessionManager --\u003e\n\t\u003cbean id=\"sessionManager\" class=\"org.apache.shiro.web.session.mgt.DefaultWebSessionManager\"\u003e\n\t\t\u003cproperty name=\"sessionDAO\" ref=\"redisSessionDAO\" /\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003c!-- cacheManager --\u003e\n\t\u003cbean id=\"cacheManager\" class=\"cn.easyproject.shirorediscache.RedisCacheManager\"\u003e\n\t\t\u003cproperty name=\"redisTemplate\" ref=\"redisTemplate\" /\u003e\n\t\u003c/bean\u003e\n\t```\n\n\n\n\u003e NOTE\n\u003e EasyShiro-Redis-Cache don't support SimpleAuthenticationInfo created by this constructor `org.apache.shiro.authc.SimpleAuthenticationInfo.SimpleAuthenticationInfo(Object principal, Object hashedCredentials, ByteSource credentialsSalt, String realmName)`.\n\u003e Please use `org.apache.shiro.authc.SimpleAuthenticationInfo.SimpleAuthenticationInfo(Object principal, Object hashedCredentials, String realmName)` instead.\n\n\n## End\n\nEmail：\u003cinthinkcolor@gmail.com\u003e\n\n[http://www.easyproject.cn](http://www.easyproject.cn \"EasyProject Home\")\n\n\n**Donation/捐助:**\n\n\u003ca href=\"http://www.easyproject.cn/donation\"\u003e\n\u003cimg alt=\"\n支付宝/微信/QQ/云闪付/PayPal 扫码支付\" src=\"http://www.easyproject.cn/thanks/donation.png\"  title=\"支付宝/微信/QQ/云闪付/PayPal 扫码支付\"  height=\"320\" width=\"320\"\u003e\u003c/img\u003e\u003c/a\u003e\n\u003cdiv\u003e支付宝/微信/QQ/云闪付/PayPal\u003c/div\u003e\n\n\u003cbr/\u003e\n\n我们相信，每个人的点滴贡献，都将是推动产生更多、更好免费开源产品的一大步。\n\n**感谢慷慨捐助，以支持服务器运行和鼓励更多社区成员。**\n\nWe believe that the contribution of each bit by bit, will be driven to produce more and better free and open source products a big step.\n\n**Thank you donation to support the server running and encourage more community members.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fushelp%2Feasyshiro-redis-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fushelp%2Feasyshiro-redis-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fushelp%2Feasyshiro-redis-cache/lists"}