Fork me on GitHub
#clojure
<
2023-12-20
>
Oliver Marks14:12:18

Anyone got any suggestions for something like redis which doese not require a server which can be used for local dev, probably end up using a key value server down the line but I would like something that will work nicely locally and for testing etc which I can switch out later on

p-himik14:12:50

If everything is in the same process and doesn't require any Redis-specific functionality, then you should be able to use a plain queue or a map.

👍 1
clyfe14:12:29

datascript ?

Oliver Marks14:12:15

I was hoping for some level of persistence, datascript does not feel like a great fit as I am not storing db like data just temporary expiring data

isak14:12:49

Haven't tried it yet, but maybe this one: https://github.com/juji-io/datalevin

isak14:12:03

(more features than you need, but still)

vinnyataide14:12:39

do you need a separate process to store on memory?

respatialized14:12:12

https://github.com/tonsky/datascript/blob/master/docs/storage.md Datascript added support for storage in a recent release.

🆒 2
Oliver Marks14:12:36

datascript / datalog does not really feel appropriate, I already have xtdb but I want to store temporary data hashmap style with a little bit of persistence, leveldb may be an option just trying to figure out if you need a server like redis

p-himik14:12:00

Just a plain kv store can be covered by many, many products. It doesn't even have to be Clojure-related if you throw in EDN or Transit to (de)serialize the data.

isak14:12:37

If you need just key value store and nothing else, I think the standard choice is rocksDB, which does not require a server. Or Sqlite and just add a key-value table.

🎯 1
Oliver Marks14:12:13

that's what I am basically after a key value store with persisteance with out an extra software like redis, ie via a library

respatialized14:12:23

you don't need to use datalog to use datascript as a simple k/v store. https://tonsky.me/blog/datascript-2/ almost never uses the query interface: > "...in 3 years of full-time web app development with DataScript I haven’t used a single query. ...I find it faster to use direct index access for simple stuff."

Oliver Marks14:12:30

oh rocks that could be an option I have that for xtdb already

clyfe14:12:27

rocks is leveldb fork

👍 1
Oliver Marks14:12:10

It's not something I know much about rocks now to find a clojure library for it 🙂

respatialized14:12:43

If you want to avoid additional external dependencies (which would be my recommendation unless you're absolutely sure your use case requires them because of the complexity they are likely to add), and you don't need to worry about synchronizing or sharing state (which it sounds like you don't), there are also very simple libraries like https://github.com/jimpil/duratom which let you persist the state of a Clojure atom to disk.

Oliver Marks15:12:55

I think I will use rocks as I have that as a local store for xtdb so I already have a dependency for that, duratom sounds exactly like the sort of thing I was looking for so worth keeping in mind for other projects

Oliver Marks21:12:48

Actually i went with duratom in the end, it lets you choose the store so I can start with a file based store and switch to redis later on nice little library as it works the same as an atom, only missing expiring keys but I created a little wrapper for that so thanks for that suggestion @UFTRLDZEW

vinnyataide14:12:08

hello folks. anyone got this error before when using praticalli clj config?

clojure -M:repl/reloaded
Syntax error compiling at (portal/runtime/jvm/server.clj:33:5).
No such var: server/as-channel

Full report at:
/var/folders/x_/60t44xz12xb5cs_ztp_tn_mm0000gn/T/clojure-9106562756449380086.edn
I just installed everything
java --version
openjdk 21.0.1 2023-10-17 LTS

clj --version
Clojure CLI version 1.11.1.1429

p-himik14:12:20

I don't use that config myself, but it feels like an incompatibility between some dependencies. Maybe something overrides the dependency on httpkit that Portal has with some old version?

dpsutton14:12:38

server/as-channel comes from [org.httpkit.server :as server] My suspicion is that you are getting an older version of http kit

dpsutton14:12:30

it wants http-kit/http-kit {:mvn/version "2.7.0"}. Do you know how to find out what version you are getting? And can you post your full deps.edn file here?

vinnyataide14:12:31

{:paths [:clj-paths :resource-paths]
 :aliases {:clj-paths ["src"]
           :resource-paths ["resources"]
           :dev {:extra-deps {org.clojure/tools.deps {:mvn/version "0.18.1374"}}}}
 :deps {org.clojure/clojure {:mvn/version "1.10.1"}
        hiccup/hiccup {:mvn/version "1.0.5"}
        http-kit/http-kit {:mvn/version "2.3.0"}
        metosin/reitit {:mvn/version "0.3.9"}
        ring/ring-defaults {:mvn/version "0.3.2"}
        com.stuartsierra/component {:mvn/version "1.1.0"}
        aero/aero {:mvn/version "1.1.6"}
        yogthos/config {:mvn/version "1.1.4"}}}

dpsutton14:12:45

you specify version 2.3.0 which is too old

vinnyataide14:12:47

looks like it

dpsutton14:12:49

change that to 2.7.0

vinnyataide14:12:02

that didn’t error before installing praticalli

vinnyataide14:12:17

but that’s maybe because I’ve deleted the .clojure which had a cache folder maybe

vinnyataide14:12:20

worked like a charm

🎉 1
Ed20:12:32

Hello everybody. Is there a way to tell if a function was AOT compiled when it's executed? Context - I have a macro that does a bunch of work at macro expansion time and calculates a big data-structure, which is transformed by a generated function. I'd like to be able to re-calculate that structure "in development". The expectation is that the code will be AOT'd before deployment so if it's not AOT'd it's not deployed, and I can re-do the work. Is this a complicated/stupid thing to do?

hiredman20:12:32

Macros are run before aot compilation, so when you load aot compiled code macros have already been expanded away

Ed20:12:55

Yes. That's why the work is being done at macro expansion time, so it doesn't need to happen later. But when I'm messing about at the repl, I want to re-run the work when I execute the generated function, so I was looking for a (was-aotd?) type thing to re-run the work, cos it depends on some files that I might have changed on my machine for testing.

Ed20:12:35

It's not a massive deal - I can just re-eval the definition, and it re-expands the macro - I just sometimes forget, and I was wondering how hard it would be to work around.

Ed20:12:57

I guess I could see if something nrepl looking was on the classpath ... but that seems even more hacky 😉

Ed20:12:15

Or I could set an env var during the aot process, and capture that value? if it's not there re-do the work ... but I feel like i'd rather not change the ci process just cos I forgot to eval something a few times ...

Ed21:12:32

I just feel like I've not had the good idea yet ...

hiredman21:12:40

very hesitant to suggest this, since I am not wild about the idea of distinguishing between aot compilation and not, but

(def aot (atom true))

(defmacro f []
  (reset! aot false)
  nil)

(f)

(defn aot? []
  @aot)

phill22:12:39

That smells brittle

Ed22:12:40

@U0NCTKEV8 thanks - I'll try that and see how it breaks 😉