Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
ba9a7263
Commit
ba9a7263
authored
Apr 30, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow the registration of third party cache and session drivers.
parent
c49c6036
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
2 deletions
+50
-2
start.php
application/start.php
+1
-1
cache.php
laravel/cache.php
+25
-1
session.php
laravel/session.php
+24
-0
No files found.
application/start.php
View file @
ba9a7263
...
...
@@ -170,4 +170,4 @@ date_default_timezone_set(Config::get('application.timezone'));
if
(
!
Request
::
cli
()
and
Config
::
get
(
'session.driver'
)
!==
''
)
{
Session
::
load
();
}
}
\ No newline at end of file
laravel/cache.php
View file @
ba9a7263
<?php
namespace
Laravel
;
defined
(
'DS'
)
or
die
(
'No direct script access.'
)
;
<?php
namespace
Laravel
;
use
Closure
;
class
Cache
{
...
...
@@ -9,6 +9,13 @@ class Cache {
*/
public
static
$drivers
=
array
();
/**
* The third-party driver registrar.
*
* @var array
*/
public
static
$registrar
=
array
();
/**
* Get a cache driver instance.
*
...
...
@@ -45,6 +52,11 @@ class Cache {
*/
protected
static
function
factory
(
$driver
)
{
if
(
isset
(
static
::
$registrar
[
$driver
]))
{
return
static
::
$registrar
[
$driver
]();
}
switch
(
$driver
)
{
case
'apc'
:
...
...
@@ -70,6 +82,18 @@ class Cache {
}
}
/**
* Register a third-party cache driver.
*
* @param string $driver
* @param Closure $resolver
* @return void
*/
public
static
function
register
(
$driver
,
Closure
$resolver
)
{
static
::
$registrar
[
$driver
]
=
$resolver
;
}
/**
* Magic Method for calling the methods on the default cache driver.
*
...
...
laravel/session.php
View file @
ba9a7263
...
...
@@ -9,6 +9,13 @@ class Session {
*/
public
static
$instance
;
/**
* The third-party driver registrar.
*
* @var array
*/
public
static
$registrar
=
array
();
/**
* The string name of the CSRF token stored in the session.
*
...
...
@@ -47,6 +54,11 @@ class Session {
*/
public
static
function
factory
(
$driver
)
{
if
(
isset
(
static
::
$registrar
[
$driver
]))
{
return
static
::
$registrar
[
$driver
]();
}
switch
(
$driver
)
{
case
'apc'
:
...
...
@@ -105,6 +117,18 @@ class Session {
return
!
is_null
(
static
::
$instance
);
}
/**
* Register a third-party cache driver.
*
* @param string $driver
* @param Closure $resolver
* @return void
*/
public
static
function
register
(
$driver
,
Closure
$resolver
)
{
static
::
$registrar
[
$driver
]
=
$resolver
;
}
/**
* Magic Method for calling the methods on the session singleton instance.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment