Class: FSSM::Cache

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/vendor/fssm/cache.rb

Defined Under Namespace

Modules: Common Classes: Node

Instance Method Summary collapse

Constructor Details

#initializeCache

Returns a new instance of Cache.



117
118
119
120
# File 'lib/vendor/fssm/cache.rb', line 117

def initialize
  @mutex = Mutex.new
  super
end

Instance Method Details

#clearObject



122
123
124
125
126
# File 'lib/vendor/fssm/cache.rb', line 122

def clear
  @mutex.lock
  @children.clear
  @mutex.unlock
end

#directoriesObject



159
160
161
# File 'lib/vendor/fssm/cache.rb', line 159

def directories
  ftype('directory')
end

#filesObject



155
156
157
# File 'lib/vendor/fssm/cache.rb', line 155

def files
  ftype('file')
end

#set(path) ⇒ Object



128
129
130
131
132
133
# File 'lib/vendor/fssm/cache.rb', line 128

def set(path)
  unset(path)
  node = descendant!(path)
  node.from_path(path)
  node.mtime
end

#unset(path = '/') ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/vendor/fssm/cache.rb', line 135

def unset(path='/')    
  key = sanitize_key(path)

  if key.empty?
    self.clear
    return nil
  end
  
  segment = key.pop
  node = descendant(key)

  return unless node
  
  @mutex.lock
  node.remove_child(segment)
  @mutex.unlock    
  
  nil
end