Class: WirisPlugin::FolderTreeStorageAndCache
- Inherits:
-
Object
- Object
- WirisPlugin::FolderTreeStorageAndCache
- Extended by:
- StorageAndCacheInterface
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb
Constant Summary collapse
- @@backwards_compat =
true
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#cacheFormula ⇒ Object
Returns the value of attribute cacheFormula.
-
#config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #codeDigest(content) ⇒ Object
- #decodeDigest(digest) ⇒ Object
- #deleteCache ⇒ Object
- #getExtension(service) ⇒ Object
- #init(obj, config, cache, cacheFormula) ⇒ Object
-
#initialize ⇒ FolderTreeStorageAndCache
constructor
A new instance of FolderTreeStorageAndCache.
- #retreiveData(digest, service) ⇒ Object
- #storeData(digest, service, stream) ⇒ Object
Methods included from StorageAndCacheInterface
Constructor Details
#initialize ⇒ FolderTreeStorageAndCache
Returns a new instance of FolderTreeStorageAndCache.
21 22 23 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 21 def initialize() super() end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
19 20 21 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 19 def cache @cache end |
#cacheFormula ⇒ Object
Returns the value of attribute cacheFormula.
20 21 22 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 20 def cacheFormula @cacheFormula end |
#config ⇒ Object
Returns the value of attribute config.
11 12 13 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 11 def config @config end |
Class Method Details
.backwards_compat ⇒ Object
13 14 15 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 13 def self.backwards_compat @@backwards_compat end |
.backwards_compat=(backwards_compat) ⇒ Object
16 17 18 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 16 def self.backwards_compat=(backwards_compat) @@backwards_compat = backwards_compat end |
Instance Method Details
#codeDigest(content) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 29 def codeDigest(content) digest = Md5Tools::encodeString(content) begin self.cacheFormula::set(digest + ".ini",Bytes::ofData(Utf8::toBytes(content))) end return digest end |
#decodeDigest(digest) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 36 def decodeDigest(digest) data = self.cacheFormula::get(digest + ".ini") if data != nil return Utf8::fromBytes(data::getData()) else return nil end end |
#deleteCache ⇒ Object
66 67 68 69 70 71 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 66 def deleteCache() cache = CacheImpl.new(self.config) begin cache::deleteAll() end end |
#getExtension(service) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 57 def getExtension(service) if (service == "png") return "png" end if (service == "svg") return "svg" end return service + ".txt" end |
#init(obj, config, cache, cacheFormula) ⇒ Object
24 25 26 27 28 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 24 def init(obj, config, cache, cacheFormula) self.config = config self.cache = cache self.cacheFormula = cacheFormula end |
#retreiveData(digest, service) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb', line 44 def retreiveData(digest, service) data = self.cache::get((digest + ".") + getExtension(service)) if data != nil return data::getData() else return nil end end |