NAME
NetSDS::Session
SYNOPSYS
use NetSDS::Session
ITEMS
- SESSION_ID
-
Current session_id;
- MEMCACH
-
object Cache::Memcached::Fast
- SESSION
-
session - a perl structure like this { order => desc, filter => non_active }
- new
-
Constructor. The object is an array ref. It takes a structure like this: { host => 'localhost', port => 12211 }. Calls a sub when initializing of a memcached server provides and returns the object NetSDS::Session.
Example: my $session = NetSDS::Session->new( host => 'localhost', port => '12211' );
- init
-
This method calls from a constructor. It provides an initializing the connection to a memcached server with params that has been taken by a constructor (params of a memcached server). Work with memcached server provides by an object Cache::Memcached::Fast. Params of a Cache::Memcached::Fast object:
serialize_methods => [ \&JSON::encode_json, \&JSON::decode_json ], compress_threshold => -1, connect_timeout => 0.25, close_on_error => true, failure_timeout => 10 sec
Notice: If there is no host or port for memcached, it wouldn't be an error. Returns an object NetSDS::Session in any case.
- set_session
-
This method takes a session_id of the user's session. According to a session_id (has session been stored earlier and server params) there could be several cases:
- when there is no session in server initialize an empty hash ref {} for a new session. - when server is not initialize (this happens when you didn't gave a host or a port into constructor initialize an empty hash ref (similar to a previous case) but notice that this session wouldn't be stored - when session exists in server get this session Example: $session->set_session($session_id);
Returns an object NetSDS::Session
- get_session
-
Returns a current session_id.
Example: $session->get_session
- set
-
Takes a key and value that should be added or replaced in current session. Notice: this method doesn't provide setting params into server. It's just connect with a perl-structure that has been get from a server by set_session method. For storing session the method $session->close_session should be used.
Example: $session->set('order', 'id desc');
- get
-
Takes a key for a value that has been saved in session earlier or undef.
Example: $session->get('order').
- delete
-
Takes a key that should be remover from current session.
Example: $sessopn->delete('order');
- close_session
-
This method provides storing current session. In case that there is no server (host or port hasn;t been taken by constructor), session wouldnt be stored.
Example: $session->close_session.
After closing session you couldn't work with it.
- clear
-
This method deletes current session from server.