Redis is installed
OSF Open Source Cache middleware
Description: IIS, Redis cache (available for distributed systems) was implemented in the 1.0 version class library
1. IIS
2. Redis
One, add files to the project
A, quote ServiceStack 3.9.60 Unlimited plate
Related files http://pan.baidu.com/s/1kVJFEMr Password: 2XVT
B, reference OSF. DataCache.dll
First: Tools-nuget Package Manager-Package Manager console input:install-package OSF. Datacache
First: Tool-nuget Package Manager-NuGet Package search input for Management solution:OSF. Datacache
Second, the Code implementation
//get cached data can be saved to a profile, or configuration center according to your own project parameters #regionThis piece can be placed in a global file.Redisconfigmodel Redismodel=NewRedisconfigmodel (); Redismodel.readwritehosts="127.0.0.1:6379"; Redismodel.readonlyhosts="127.0.0.1:6379"; Redismodel.maxwritepoolsize= -; Redismodel.maxreadpoolsize= -; Redismodel.localcachetime= the; Redismodel.autostart=true; Redismodel.recordelog=true; Redismodel.defaultdb=4; OSF. DataCache.RedisCacheHelper.Init (Redismodel); #endregion //Get Cache stringCacheKey =string. Format ("OSF. Datacache.cachetest"); stringobj = OSF. datacache.rediscachehelper.getcache<string>(CacheKey); if(obj = =NULL) {OSF. DataCache.RedisCacheHelper.SetCache (CacheKey,"----------test Data--------"); }
View Code
Third, view the data
Visual Tools-redis Desktop Manager
Note: In the spirit of learning, exercise purposes, there are inappropriate, or have a good idea please enlighten us. Interested friends come together:(315499472)
OSF. Datacache Open Source Cache middleware use