dymokomi/luce-prism
Source of release 0.6.1
0.6.1 / src / evaluation / cache_api.lucb
## Concrete foreign-boundary carriers for the generic Base evaluation cache.
import interop
import ownership
from evaluation.cache import EvalCache, EvalKey
from document import Document
from value import Value
pub struct ValueCache:
var data: EvalCache[Value]
pub func init():
return
pub func valid(key: EvalKey) -> bool:
return self.data.valid(key)
pub func invalidate():
self.data.invalidate()
pub func evaluate(key: EvalKey, producer: interop.Callback[EvalKey, interop.Reference[Value]]) -> interop.Reference[Value]!:
return try self.data.evaluate(key, producer)
pub func trace(visit: func(ownership.Object*, void*) -> unit, context: void*):
self.data.trace(visit, context)
pub func close():
self.data.close()
pub let value_cache_type = interop.Type[ValueCache]("Prism value cache", ValueCache.close, ValueCache.trace, closeable = true)
pub struct DocumentCache:
var data: EvalCache[Document]
pub func init():
return
pub func valid(key: EvalKey) -> bool:
return self.data.valid(key)
pub func invalidate():
self.data.invalidate()
pub func evaluate(key: EvalKey, producer: interop.Callback[EvalKey, interop.Reference[Document]]) -> interop.Reference[Document]!:
return try self.data.evaluate(key, producer)
pub func trace(visit: func(ownership.Object*, void*) -> unit, context: void*):
self.data.trace(visit, context)
pub func close():
self.data.close()
pub let document_cache_type = interop.Type[DocumentCache]("Prism document cache", DocumentCache.close, DocumentCache.trace, closeable = true)