Class: RackJwtAegis::SolidCacheAdapter
- Inherits:
-
CacheAdapter
- Object
- CacheAdapter
- RackJwtAegis::SolidCacheAdapter
- Defined in:
- lib/rack_jwt_aegis/cache_adapter.rb
Overview
Solid Cache adapter (Rails 8+)
Instance Method Summary collapse
- #clear ⇒ Object
- #delete(key) ⇒ Object
-
#initialize(options = {}) ⇒ SolidCacheAdapter
constructor
A new instance of SolidCacheAdapter.
- #read(key) ⇒ Object
- #write(key, value, expires_in: nil) ⇒ Object
Methods inherited from CacheAdapter
Constructor Details
#initialize(options = {}) ⇒ SolidCacheAdapter
Returns a new instance of SolidCacheAdapter.
224 225 226 227 228 229 230 231 232 233 |
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 224 def initialize( = {}) super # Solid Cache should be available in Rails environment unless defined?(SolidCache) raise CacheError, "SolidCache not available. Ensure you're using Rails 8+ with Solid Cache configured." end @cache = [:cache_instance] || SolidCache end |
Instance Method Details
#clear ⇒ Object
257 258 259 260 261 262 |
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 257 def clear @cache.clear true rescue StandardError => e raise CacheError, "SolidCache clear error: #{e.}" end |
#delete(key) ⇒ Object
250 251 252 253 254 255 |
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 250 def delete(key) @cache.delete(key.to_s) true rescue StandardError => e raise CacheError, "SolidCache delete error: #{e.}" end |
#read(key) ⇒ Object
235 236 237 238 239 240 |
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 235 def read(key) value = @cache.read(key.to_s) deserialize_value(value) rescue StandardError => e raise CacheError, "SolidCache read error: #{e.}" end |
#write(key, value, expires_in: nil) ⇒ Object
242 243 244 245 246 247 248 |
# File 'lib/rack_jwt_aegis/cache_adapter.rb', line 242 def write(key, value, expires_in: nil) serialized_value = serialize_value(value) @cache.write(key.to_s, serialized_value, expires_in: expires_in) true rescue StandardError => e raise CacheError, "SolidCache write error: #{e.}" end |