Revision 253

Date:
2012/09/26 16:26:49
Author:
ahitrov
Revision Log:
Sessions through Memcached
Files:

Legend:

 
Added
 
Removed
 
Modified
  • koi8/plugins/session/config.proto

     
    6 6 #############################################################################
    7 7
    8 8 PLUGINS += session
    9 PROJECT_REQUIRED += Apache-Session
    9 PROJECT_REQUIRED += Apache-Session Apache-Session-Memcached
    10 10 PROJECT_REQUIRED += JSON-XS
    11 11 PROJECT_REQUIRED += P-WebFetcher
    12 12
     
    32 32
    33 33 REWRITE += SESSION_STORAGE SESSION_DOMAIN SESSION_LIFETIME SESSION_EXPIRES
    34 34
    35 ########################################################################
    35 ###########################################################################
    36 36 #
    37 37 # SESSION_DOMAIN
    38 38 # �����, �� ������� �������� ������. ����� �� ���������
    39 39 # SESSION_STORAGE
    40 # ��������� ��� �������� ������. ��������: POSTGRES � FILE
    40 # ��������� ��� �������� ������. ��������: POSTGRES, MEMCACHED, FILE
    41 # ��� ������ ������ ����� Memcached � ������� ������� ��� �����������
    42 # ������ ���� ����������� ���������
    43 # MEMCACHED_ENABLE = 1
    44 # MEMCACHED_SERVERS = ������ �������� � �������, ����������� ���������
    41 45 # SESSION_LIFETIME
    42 46 # ����� ����� ������ �� �����������. �������� � �����, ������������
    43 47 # ��� ��������� � crontab ������� ������� �� services
    44 48 # SESSION_EXPIRES
    45 49 # ����� ����� ���� ������. �������� � ������� Apache
    46 50 #
    47 ########################################################################
    51 ###########################################################################
    48 52
    49 53
    50 54 ### AUTH::FaceBook
  • koi8/plugins/session/lib/session/Keeper.pm

     
    7 7 use Apache::Cookie;
    8 8 use Apache::Session::File;
    9 9 use Apache::Session::Postgres;
    10 use Apache::Session::Memcached;
    10 11 use Contenido::Globals;
    11 12 use Data::Dumper;
    12 13
     
    205 206 Handle => $keeper->SQL,
    206 207 };
    207 208 };
    209 } elsif ( $state->{session}->storage eq 'MEMCACHED' ) {
    210 eval {
    211 tie %session, 'Apache::Session::Memcached', $sid, {
    212 Handler => $keeper->{session}->MEMD,
    213 Expiration => $state->{session}->{lifetime},
    214 # Servers => $state->{session}->memcached_servers,
    215 # NoRehash => 1,
    216 # Readonly => 0,
    217 # Debug => $DEBUG,
    218 # CompressThreshold => 10_000
    219 };
    220 };
    208 221 } else {
    209 222 eval {
    210 223 tie %session, 'Apache::Session::File', $sid, {
    211 Directory => $state->session->session_dir,
    224 Directory => $state->{session}->session_dir,
    212 225 };
    213 226 };
    214 227 }
     
    231 244 Handle => $keeper->SQL,
    232 245 };
    233 246 };
    247 } elsif ( $state->{session}->storage eq 'MEMCACHED' ) {
    248 eval {
    249 tie %session, 'Apache::Session::Memcached', undef, {
    250 Handler => $keeper->{session}->MEMD,
    251 Expiration => $state->{session}->{lifetime},
    252 # Servers => $state->{session}->memcached_servers,
    253 # NoRehash => 1,
    254 # Readonly => 0,
    255 # Debug => $DEBUG,
    256 # CompressThreshold => 10_000
    257 };
    258 };
    234 259 } else {
    235 260 eval {
    236 261 tie %session, 'Apache::Session::File', undef, {
  • koi8/plugins/session/lib/session/State.pm.proto

     
    12 12 bless $self, $class;
    13 13
    14 14 # ������� ������������ �������
    15 $self->{project} = '@PROJECT@';
    16
    15 17 $self->{db_type} = 'none';
    16 18 $self->{storage} = '@SESSION_STORAGE@' || 'FILE'; ## ��������: FILE POSTGRES MEMCACHED
    17 19 $self->{session_dir} = '@SESSIONS@';
     
    39 41 $self->{debug} = '';
    40 42 $self->{store_method} = '';
    41 43 $self->{cascade} = '';
    42 $self->{memcached_enable} = '';
    43 44
    45 $self->{memcached_enable} = lc( '@MEMCACHED_ENABLE@' ) eq 'yes' ? 1 : 0;
    46 $self->{memcached_backend} = '@MEMCACHED_BACKEND@';
    47 $self->{memcached_select_timeout} = '@MEMCACHED_SELECT_TIMEOUT@' || 0.2;
    48 $self->{memcached_servers} = [qw(@MEMCACHED_SERVERS@)];
    49 $self->{memcached_enable_compress} = lc( '@MEMCACHED_ENABLE_COMPRESS@' ) eq 'yes' ? 1 : 0;
    50 $self->{memcached_delayed} = lc('@MEMCACHED_DELAYED@') eq 'yes' ? 1 : 0;
    51 $self->{memcached_set_mode} = lc('@MEMCACHED_SET_MODE@') eq 'add' ? 'add' : 'set';
    52 $self->{memcached_busy_lock} = 60;
    53 $self->{memcached_namespace} = lc( $self->{'project'} ).'|plugin_session|';
    54
    55 $self->{memcached_object_expire} = undef;
    56
    57 $self->{storage} = 'FILE' if $self->{storage} eq 'MEMCACHED' && !$self->{memcached_enable};
    58
    44 59 $self->{facebook_app_id} = '@FACEBOOK_APP_ID@';
    45 60 $self->{facebook_app_secret} = '@FACEBOOK_APP_SECRET@';
    46 61 $self->{facebook_redirect_uri} = '@FACEBOOK_REDIRECT_URL@';
     
    92 107 db_name
    93 108 db_user
    94 109 db_password
    95 data_directory images_directory binary_directory preview debug store_method cascade memcached_enable
    110
    111 memcached_enable
    112 memcached_servers
    113 memcached_select_timeout
    114 memcached_backend
    115 memcached_enable_compress
    116 memcached_set_mode
    117 memcached_object_expire
    118 memcached_busy_lock
    119 memcached_delayed
    120 memcached_namespace
    121
    122 data_directory
    123 images_directory
    124 binary_directory
    125 preview
    126 debug
    127 store_method
    128 cascade
    96 129 );
    97 130 }
    98 131