apr

apr

Questions about Cachex

Hello!

Sorry if this is obvious, but I couldn’t find an answer in the docs.

I am using the Cachex library. How does one go about locking a row? Is it done via transaction/4? Is there a more lightweight version where I can just lock a row, perform some operation, and then unlock it?

Thanks!

Marked As Solved

OvermindDL1

OvermindDL1

That’s what the Action Block transaction would be. execute just runs in the cache process for speed, but does not synchronization, transaction is what does synchronization. :slight_smile:

Also Liked

OvermindDL1

OvermindDL1

Or /3 if no options needed yep:
https://hexdocs.pm/cachex/action-blocks.html#transaction-blocks

apr

apr

Perfect, thanks @OvermindDL1!

apr

apr

Just for posterity’s sake, Cachex.get_and_update/4 has an implicit transaction underneath. So for this particular operation, transactions are not needed, but @OvermindDL1 's answer is the way to go for operations that do need transactions.

Last Post!

apr

apr

Just for posterity’s sake, Cachex.get_and_update/4 has an implicit transaction underneath. So for this particular operation, transactions are not needed, but @OvermindDL1 's answer is the way to go for operations that do need transactions.

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31525 112
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement