0

I found a Lua LRU cache implementation here lua-lru

Is this thread-safe, can this be used with mod_lua?

Community
  • 1
  • 1
callow
  • 517
  • 1
  • 4
  • 15
  • This library did not share anything so yes. But i do not think you can use this library from several threads. – moteus Aug 30 '16 at 17:22
  • Vanilla Lua doesn't support threads, so "everything" is thread-safe. Most `mod_$LANGUAGE` Apache plugins, as far as I can tell, run separate processes for each request, so there's nothing to share anyway. – Colonel Thirty Two Aug 30 '16 at 19:55
  • 1
    If modulewritten on C and use e.g. static variables then it may not be thread safe. But pure lua modules which do mot use any not thread safe libs are thread safe – moteus Aug 30 '16 at 20:17
  • @moteus Is there then any lru cache implementation that would work with mod_lua? – callow Aug 31 '16 at 06:19
  • An alternative could be using mod_lua's inter vm cache instead of the map, to store the k-v pairs, and the size and the pointers, but then updating them in multi-thread would not be safe. Wondering if there's an alternative. – callow Sep 13 '16 at 06:03

0 Answers0