Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove file from memory after expire #1

Open
kostya opened this issue Jul 5, 2016 · 4 comments
Open

remove file from memory after expire #1

kostya opened this issue Jul 5, 2016 · 4 comments

Comments

@kostya
Copy link

kostya commented Jul 5, 2016

for each file add access time, and allow to expire rare-access keys. this is should save process memory.

like this: BakedFileSystem.load("dir", expire_in: 1.hour)

@schovi
Copy link
Owner

schovi commented Jul 5, 2016

@kostya Is there any native tool for that?

My naive idea is to do it manually like:

def read
  return @string if @string

  @string = ....

  if @expire_in
    spawn do
      sleep @expire_id
      @string = nil
    end
  end

  @string
end

@kostya
Copy link
Author

kostya commented Jul 5, 2016

i am using every pattern, https://gist.github.com/kostya/7388768b1363e95852c5367a16b5900f#file-xx-cr-L19

i think you should create one loop for class, like this:

every(10.seconds) do
  @files.each do |file|
    file.expire! if file.expired?
  end
end

@kostya
Copy link
Author

kostya commented Jul 5, 2016

hm, btw you can you also https://github.com/kostya/memory_cache, this is actually memory cache with expires, but this is not supported access time right now

@schovi
Copy link
Owner

schovi commented Nov 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants