File tree 1 file changed +37
-3
lines changed
1 file changed +37
-3
lines changed Original file line number Diff line number Diff line change 1
- require 'sprockets/caching'
2
-
3
1
module Opal
4
2
class SourceMapServer
3
+ # Carelessly taken from Sprockets::Caching (Sprockets v2)
5
4
class Cache
6
- include ::Sprockets ::Caching
7
5
def initialize
8
6
@cache = { }
9
7
end
8
+
10
9
attr_reader :cache
10
+
11
+ def cache_get ( key )
12
+ # `Cache#get(key)` for Memcache
13
+ if cache . respond_to? ( :get )
14
+ cache . get ( key )
15
+
16
+ # `Cache#[key]` so `Hash` can be used
17
+ elsif cache . respond_to? ( :[] )
18
+ cache [ key ]
19
+
20
+ # `Cache#read(key)` for `ActiveSupport::Cache` support
21
+ elsif cache . respond_to? ( :read )
22
+ cache . read ( key )
23
+
24
+ else
25
+ nil
26
+ end
27
+ end
28
+
29
+ def cache_set ( key , value )
30
+ # `Cache#set(key, value)` for Memcache
31
+ if cache . respond_to? ( :set )
32
+ cache . set ( key , value )
33
+
34
+ # `Cache#[key]=value` so `Hash` can be used
35
+ elsif cache . respond_to? ( :[]= )
36
+ cache [ key ] = value
37
+
38
+ # `Cache#write(key, value)` for `ActiveSupport::Cache` support
39
+ elsif cache . respond_to? ( :write )
40
+ cache . write ( key , value )
41
+ end
42
+
43
+ value
44
+ end
11
45
end
12
46
13
47
def self . get_map_cache ( sprockets , logical_path )
You can’t perform that action at this time.
0 commit comments