Code Monkey home page Code Monkey logo

Comments (7)

kataras avatar kataras commented on May 14, 2024 1

I'll try to explain you the flow:

  • .Start -> if session database attached then load from that storage and save to the memory, otherwise load from memory. The load from database is done once on the initialize of each session.
  • .Get (important) -> load from memory, if database attached then it already loaded the values from database on the .Start action, so it will retrieve the data from the memory (fast)
  • .Set -> set to the memory, if database attached then update the storage
  • .Delete -> clear from memory, if database attached then update the storage
  • .Destroy -> destroy from memory and client cookie, if database attached then update the storage with empty values, empty values means delete the storage with that specific session id.

Using everything else except memory is slower than memory but database is fetched once at each session and its updated on every Set, Delete, Destroy at call-time (all other external sessions managers out there work different than Iris one as far as I know, you may find them more suited to your application, it depends).

I hope that your questions are being answered.

from iris.

speedwheel avatar speedwheel commented on May 14, 2024 1

Thanks for the answer, it works similar like I was thinking and I consider that Iris Sessions are suitable for my project.

from iris.

kataras avatar kataras commented on May 14, 2024

It's the first opened issue...

Redis should work, it works on me if you have any issues please contact on the chat, we may find what's wrong with your setup.

However, you can use the file storage session database, example: https://github.com/kataras/iris/blob/master/_examples/sessions/database/file/main.go

from iris.

speedwheel avatar speedwheel commented on May 14, 2024

I made it work with the file storage from the example above.

One thing I noticed is that on line 108 inside this file "github.com/kataras/iris/sessions/sessiondb/file", that there is no error checking for ioutil.WriteFile, in case you don't have the right permissions to create a file.

@kataras Is the file session storage slower than default sessions?

from iris.

kataras avatar kataras commented on May 14, 2024

@speedwheel thanks for the info, it has been fixed.

Yes anything else than memory storage is slower. This session manager uses always the memory (high performance but may need more RAM) and if you want persistence then you attach a session database (like file storage and redis), simple and efficient. We did use this session manager(the iris one which I authored) at production, but nothing stops you to use an external one, remember? Iris is compatible with everything.

from iris.

speedwheel avatar speedwheel commented on May 14, 2024

I understand, one last question:

Is sess.Start(ctx).Get() slower using the file session storage? I am not really sure how it works, but I am thinking the file session is than dumped in the memory, so it should be the same speed?

from iris.

heyouzhi avatar heyouzhi commented on May 14, 2024

.Get (important) -> load from memory, if database attached then it already loaded the values from database on the .Start action, so it will retrieve the data from the memory (fast)

As @kataras said, session Get only fetch values from database once,but if the values in database updated by other server node,the session in memory will not update! This behavior will cause memory session in many server nodes inconsistent! for example, issue #885 .

from iris.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.