This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-09-24
Channels
- # admin-announcements (17)
- # alda (5)
- # aws (4)
- # beginners (19)
- # boot (80)
- # bristol-clojurians (3)
- # cider (15)
- # clojure (257)
- # clojure-berlin (1)
- # clojure-czech (1)
- # clojure-indonesia (1)
- # clojure-nl (1)
- # clojure-poland (1)
- # clojure-russia (77)
- # clojurescript (186)
- # core-async (7)
- # core-typed (6)
- # cursive (8)
- # datomic (2)
- # devcards (2)
- # editors (45)
- # emacs (23)
- # hoplon (83)
- # jobs (1)
- # ldnclj (106)
- # leiningen (43)
- # off-topic (4)
- # onyx (31)
- # reagent (10)
- # yada (1)
trying to get the value of params[format] else return "yaml"
(fnil (:format (get-in req [:params])) "yaml")
hey clojurians, I have a program that generates thumbnail image files and I’d like to have it automatically manage the thumbnail files inside a cache, I was thinking of trying to create a new core.cache type (like described here https://github.com/clojure/core.cache/wiki/Extending). The new cache type could create files on cache misses, and delete files on evictions. Does that sound like a good way to go about it? Any other ideas on how to implement a cache of thumbnail files?
when i try to use that value i have an error, i print it in a log and it looks like
INFO: Using format clojure.core$fnil$fn__5496@a8995f2
@clojuregeek, I think get-in accepts a third param “not-found” so maybe something like this? (get-in req [:params :format] "yaml”)
@clojuregeek: your parens aren’t aligned
yeah i cut it out of a bigger sexp ... i'll try the get -in
that works @upgradingdave .. thanks! i guess i was making it bigger problem then it was
@upgradingdave: Have you tried letting the OS do the file system caching for you? Are you sure you need to hold the image in JVM memory?
@rauh, no I’d rather not hold the files in memory. I was thinking maybe have a simple lru cache that looks something like this {“path-to-file1” true, “path-tofile2” true} and then customize the evict method so that the files actually get removed from disk
I hadn’t really looked into os doing the caching. Ideally I think it’d be cool if it were all contained in the jvm though
@upgradingdave: Now I understand what you're trying to do. In that case I'd just clean them up (like a garbage collector) after a while. In that case, yes I think the LRU cache of core.cache
is not a bad idea
it’s just a toy project I’m working on so like to keep it as simple as possible
cool, thanks, @rauh, good to know I’m not way off 😉
@upgradingdave: Many file systems also have "atime" (access time) which you could use with a simple bash script to remove files after a few months if you really want to
definitely an option to just blow away older thumbnails, thanks. I thought this’d be a good chance to dive deeper into core.cache for fun mostly, so I think I’ll run with it and see what I can come up with, thanks again!