tiflolinux.org - GNU Social
  • Login

Bienvenido

  • Public

    • Public
    • Network
    • Groups
    • Popular
    • People

Conversation

Notices

  1. Ekaitz Zárraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Monday, 21-Jan-2019 16:46:25 CET Ekaitz Zárraga 👹 Ekaitz Zárraga 👹

    A random question here. #clojure but not really language-based.

    I want to store my web application's state in a file, it's a file that won't be touched too much and I'm thinking about using just a file. (edn, but could be a json file).

    The thing here is if two users change that state at the same time I can destroy the file... and... ugh

    I think I'm looking for a way to swap! an atom and automatically persist it to file in the same call.

    Any simple way to make that?

    In conversation Monday, 21-Jan-2019 16:46:25 CET from mastodon.social permalink
    • Like a goth, but older (eldergoth@sfbubble.net)'s status on Monday, 21-Jan-2019 16:51:39 CET Like a goth, but older Like a goth, but older
      in reply to

      @ekaitz_zarraga `touch` a lock-file before editing and remove it afterward, waiting if it's already present? Or did you already rule that out?
      The other thing that springs to mind is to write the file under another name, maybe involving the pid and a timestamp in the filename, then `mv` it over the top of the canonical filepath. Last edit wins, but it's at least atomic.
      And that's how you know I'm a sysadmin who writes code, not a pro developer who's been known to administer systems :)

      In conversation Monday, 21-Jan-2019 16:51:39 CET permalink
      Ekaitz Zárraga 👹 repeated this.
    • Ekaitz Zárraga 👹 (ekaitz_zarraga@mastodon.social)'s status on Monday, 21-Jan-2019 17:00:48 CET Ekaitz Zárraga 👹 Ekaitz Zárraga 👹
      in reply to

      Wait a minute!
      I can use an atom for locking the file... I'm an idiot

      In conversation Monday, 21-Jan-2019 17:00:48 CET permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

tiflolinux.org - GNU Social is a social network, courtesy of tiflolinux.org. It runs on GNU social, version 2.0.1-beta0, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All tiflolinux.org - GNU Social content and data are available under the Creative Commons Attribution 3.0 license.