Using `localcache_put` and `localcache_get` in LUA

Hello guys,

I found in your source code these lua methods (localcache_put and localcache_get) - which are not documented. Tried them on an intensive sql query and seem like working fine.

Are there any info about how this cache works? I didn’t found a way to set a duration for the cache. When does it cleans up? It’s ok to keep things in this cache?

Thanks

I found in your source code these lua methods (localcache_put and localcache_get ) - which are not documented.

These APIs in the virtual machine runtime for Lua are experimental so we’ve not documented them yet. They are not considered official APIs and are subject to change.

Are there any info about how this cache works? I didn’t found a way to set a duration for the cache. When does it cleans up? It’s ok to keep things in this cache?

The cache has no built-in eviction policy right now so you’re expected to minimize the number of objects stored in it.

The code has been designed for a specific (non-player data) orientated use case where you have static data (like CCG definitions or similar) which you’d like to load once at server start and read across VMs in a high performance way (i.e. In RPCs, etc.). The values in the cache are LValue types which means the VM does not need to encode or decode them on load.

Hope this helps but please use the API with care. :+1:

1 Like