[Rspamd-Users] Cache for module

Manuel Guesdon ml+rspamd at oxymium.net
Tue Feb 26 21:33:10 UTC 2019


Hi,

I've written a module and I'd like to cache result (in redis) based on some
task keys.
Something like:
<<
function module_cb(task)
   local key=task:get_user()

   ret,result_value=rspamd_redis_make_request_sync(task,
					     settings.redis_config,
					     redisKey,
                                             false,
                                            'GET',
                                             {key})
   if not result_value then   
      result_value=doSomething()
      rspamd_redis_make_request_sync(task,
				     settings.redis_config,
				     redisKey,
                                     true,
                                     'SETEX',
                                     {key, '20', result_value})
   end
   DoSomethingWithTheResult(result_value)
end

settings.redis_config= lua_redis.parse_redis_server('mymodule')
>>

But there's no rspamd_redis_make_request_sync function. If I use an async call
with a callback, the result come 'too late'

What is the best way to do this ?  Registering a symbol for the cache get and
make my module depending on it ?

Thank you !

Manuel 

--
______________________________________________________________________
Manuel Guesdon - OXYMIUM


More information about the Users mailing list