Sha256: b00db01b041919f752a5921cdfe1fcde4c222968f1dd1336c81e64f52f9a8a8c
Contents?: true
Size: 904 Bytes
Versions: 2
Compression:
Stored size: 904 Bytes
Contents
require 'redis' class Ollama::Documents class RedisBackedMemoryCache < MemoryCache def initialize(prefix:, url: ENV['REDIS_URL'], object_class: nil) super(prefix:) url or raise ArgumentError, 'require redis url' @url, @object_class = url, object_class @redis_cache = Ollama::Documents::RedisCache.new(prefix:, url:, object_class:) @redis_cache.extend(Ollama::Documents::Cache::Records::RedisFullEach) @redis_cache.full_each do |key, value| @data[key] = value end end attr_reader :object_class def redis @redis_cache.redis end def []=(key, value) super redis.set(pre(key), JSON(value)) end def delete(key) result = redis.del(pre(key)) super result end def clear redis.scan_each(match: "#@prefix*") { |key| redis.del(key) } super self end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ollama-ruby-0.12.1 | lib/ollama/documents/cache/redis_backed_memory_cache.rb |
ollama-ruby-0.12.0 | lib/ollama/documents/cache/redis_backed_memory_cache.rb |