jasonpunyon / rol Goto Github PK
View Code? Open in Web Editor NEWRedis, as easy as declaring an interface.
License: MIT License
Redis, as easy as declaring an interface.
License: MIT License
Add it, a la IRedisHash
, IRedisSet
, IRedisSortedSet
.
I'm using Rol and Redis to be a primary data store for stats I'm calculating from the Stack exchange data dump.
Currently, the flow is:
Get for a User; Update any properties in place for that user, and then move on to the next user. Because I'm parsing XML files, and each Row can represent a different user, I end up retrieving the same user multiple thousand times using Rol.
This works well enough; but after a few hours of running this; I end up getting a timeout from Redis::
Unhandled Exception: System.TimeoutException: Timeout performing HGET /IPostStats/photo.stackexchange.com-918603, inst: 1, mgr: ExecuteSelect, err: never, queue: 2, qu: 0, qs: 2, qc: 0, wr: 0, wq: 0, in: 0, ar: 0, IOCP: (Busy=0,Free=1000,Min=8,Max=1000), WORKER: (Busy=0,Free=32767,Min=8,Max=32767), clientName: DOR
at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 1927
at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisBase.cs:line 80
at StackExchange.Redis.RedisDatabase.HashGet(RedisKey key, RedisValue hashField, CommandFlags flags) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisDatabase.cs:line 118
at Rol.RedisOperations.GetHashValue[TKey,TValue](Store store, RedisKey hashName, TKey field)
at StackStats.Stats.Extensions.UserExtensions.GetAverageAnswersPerDay(IUser user) in c:\projects\shift\src\StatPersistence\Stats\Extensions\UserExtensions.cs:line 28
at XmlProcessor.UserProcessor.Process(XElement element, String siteName) in c:\projects\shift\src\XmlProcessor\PostProcessor.cs:line 53
at XmlProcessor.DocumentProcessor.processFile(IProcessor processor, XmlReader reader, String siteName) in c:\projects\shift\src\XmlProcessor\DocumentProcessor.cs:line 76
at XmlProcessor.DocumentProcessor.ProcessXmlDocument(String xmlFile) in c:\projects\shift\src\XmlProcessor\DocumentProcessor.cs:line 37
at StatRunner.Program.Main(String[] args) in c:\projects\shift\src\StatRunner\Program.cs:line 28
According to StackExchange.Redis issue #83; I should increase the timeout in working with Redis (to give it more time to write data to disk before giving it more operations to do).
My question here is; does Rol have any defaults / preferences for those Redis settings; and it appears Rol currently retrieves items lazily and writes them upon setting; is there any way to change that behavior to retrieve on load and write at a predetermined point?
That's not necessarily the solution; I'm just looking for what would be a better practice here.
I'm using the "Get this object if it exists, if not Create it" pattern, and one issue I'm seeing is when I get Store.Get<T>
for a complex object, it'll return an object (with default values) even if that object doesn't exist in redis. Which I didn't expect because I thought it would use the redis GET
command.
Here's the code:
public interface IA
{
string Id {get;}
IB B {get; set;}
}
public interface IB
{
IList<IC> C {get; set;}
}
And you can imagine what IC
looks like. Anyway, when I try to get an object from Redis, I get an ArgumentNullException from Jil because IA.B
is null; which I wouldn't have expected.
var user = Store.Get<IA>("myIdNotInRedis");
if (user.B == null) //throws exception here
System.ArgumentNullException was unhandled
HResult=-2147467261
Message=Value cannot be null.
Parameter name: text
Source=Jil
ParamName=text
StackTrace:
at Jil.JSON.Deserialize[T](String text, Options options) in C:\Users\kmontrose\Dropbox\jil\Jil\JSON.cs:line 4751
at Rol.FromRedisValue`1.<>c.b__1_3(RedisValue v, Store s)
at Rol.RedisOperations.GetHashValue[TKey,TValue](Store store, RedisKey hashName, TKey field)
at StackStats.Persistence.User.GetUser(String userId, String siteName) in c:\projects\shift\src\StatPersistence\Persistence\StackUser.cs:line 45
at XmlProcessor.BadgesProcessor.Process(XElement element, String siteName) in c:\projects\shift\src\XmlProcessor\BadgesProcessor.cs:line 34
at XmlProcessor.DocumentProcessor.processFile(IProcessor processor, XmlReader reader, String siteName) in c:\projects\shift\src\XmlProcessor\DocumentProcessor.cs:line 76
at XmlProcessor.DocumentProcessor.ProcessXmlDocument(String xmlFile) in c:\projects\shift\src\XmlProcessor\DocumentProcessor.cs:line 45
at StatRunner.Program.Main(String[] args) in c:\projects\shift\src\StatRunner\Program.cs:line 28
InnerException:
How I can set/get TTL for objects stored via Rol?
To use an interface with Rol, it needs to have a get only Id property. Right now if that requirement isn't met Rol throws some horrible error lazily. It should throw earlier, with a nicer message to say what's going on.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.