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
c49c6036
Commit
c49c6036
authored
Apr 30, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up the section able implementation.
parent
9dea22c3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
188 deletions
+87
-188
memcached.php
laravel/cache/drivers/memcached.php
+0
-95
memory.php
laravel/cache/drivers/memory.php
+47
-87
sectionable.php
laravel/cache/drivers/sectionable.php
+40
-6
No files found.
laravel/cache/drivers/memcached.php
View file @
c49c6036
...
@@ -16,20 +16,6 @@ class Memcached extends Sectionable {
...
@@ -16,20 +16,6 @@ class Memcached extends Sectionable {
*/
*/
protected
$key
;
protected
$key
;
/**
* Indicates that section caching is implicit based on keys.
*
* @var bool
*/
public
$implicit
=
true
;
/**
* The implicit section key delimiter.
*
* @var string
*/
public
$delimiter
=
'::'
;
/**
/**
* Create a new Memcached cache driver instance.
* Create a new Memcached cache driver instance.
*
*
...
@@ -73,19 +59,6 @@ class Memcached extends Sectionable {
...
@@ -73,19 +59,6 @@ class Memcached extends Sectionable {
}
}
}
}
/**
* Retrieve a sectioned item from the cache driver.
*
* @param string $section
* @param string $key
* @param mixed $default
* @return mixed
*/
public
function
get_from_section
(
$section
,
$key
,
$default
=
null
)
{
return
$this
->
get
(
$this
->
section_item_key
(
$section
,
$key
),
$default
);
}
/**
/**
* Write an item to the cache for a given number of minutes.
* Write an item to the cache for a given number of minutes.
*
*
...
@@ -113,20 +86,6 @@ class Memcached extends Sectionable {
...
@@ -113,20 +86,6 @@ class Memcached extends Sectionable {
}
}
}
}
/**
* Write a sectioned item to the cache.
*
* @param string $section
* @param string $key
* @param mixed $value
* @param int $minutes
* @return void
*/
public
function
put_in_section
(
$section
,
$key
,
$value
,
$minutes
)
{
$this
->
put
(
$this
->
section_item_key
(
$section
,
$key
),
$value
,
$minutes
);
}
/**
/**
* Write an item to the cache that lasts forever.
* Write an item to the cache that lasts forever.
*
*
...
@@ -148,48 +107,6 @@ class Memcached extends Sectionable {
...
@@ -148,48 +107,6 @@ class Memcached extends Sectionable {
}
}
}
}
/**
* Write a sectioned item to the cache that lasts forever.
*
* @param string $section
* @param string $key
* @param mixed $value
* @return void
*/
public
function
forever_in_section
(
$section
,
$key
,
$value
)
{
return
$this
->
forever
(
$this
->
section_item_key
(
$section
,
$key
),
$value
);
}
/**
* Get a sectioned item from the cache, or cache and return the default value.
*
* @param string $section
* @param string $key
* @param mixed $default
* @param int $minutes
* @return mixed
*/
public
function
remember_in_section
(
$section
,
$key
,
$default
,
$minutes
,
$function
=
'put'
)
{
$key
=
$this
->
section_item_key
(
$section
,
$key
);
return
$this
->
remember
(
$key
,
$default
,
$minutes
,
$function
);
}
/**
* Get a sectioned item from the cache, or cache the default value forever.
*
* @param string $section
* @param string $key
* @param mixed $default
* @return mixed
*/
public
function
sear_in_section
(
$section
,
$key
,
$default
)
{
return
$this
->
sear
(
$this
->
section_item_key
(
$section
,
$key
),
$default
);
}
/**
/**
* Delete an item from the cache.
* Delete an item from the cache.
*
*
...
@@ -217,18 +134,6 @@ class Memcached extends Sectionable {
...
@@ -217,18 +134,6 @@ class Memcached extends Sectionable {
}
}
}
}
/**
* Delete a sectioned item from the cache.
*
* @param string $section
* @param string $key
* @return void
*/
public
function
forget_in_section
(
$section
,
$key
)
{
return
$this
->
forget
(
$this
->
section_item_key
(
$section
,
$key
));
}
/**
/**
* Delete an entire section from the cache.
* Delete an entire section from the cache.
*
*
...
...
laravel/cache/drivers/memory.php
View file @
c49c6036
...
@@ -28,22 +28,16 @@ class Memory extends Sectionable {
...
@@ -28,22 +28,16 @@ class Memory extends Sectionable {
*/
*/
protected
function
retrieve
(
$key
)
protected
function
retrieve
(
$key
)
{
{
return
array_get
(
$this
->
storage
,
$key
);
if
(
$this
->
sectionable
(
$key
))
}
/**
* Retrieve a sectioned item from the cache driver.
*
* @param string $section
* @param string $key
* @param mixed $default
* @return mixed
*/
public
function
get_from_section
(
$section
,
$key
,
$default
=
null
)
{
{
$key
=
$this
->
section_item_key
(
$section
,
$key
);
list
(
$section
,
$key
)
=
$this
->
parse
(
$key
);
return
array_get
(
$this
->
storage
,
$key
,
$default
);
return
$this
->
get_from_section
(
$section
,
$key
);
}
else
{
return
array_get
(
$this
->
storage
,
$key
);
}
}
}
/**
/**
...
@@ -61,21 +55,16 @@ class Memory extends Sectionable {
...
@@ -61,21 +55,16 @@ class Memory extends Sectionable {
*/
*/
public
function
put
(
$key
,
$value
,
$minutes
)
public
function
put
(
$key
,
$value
,
$minutes
)
{
{
array_set
(
$this
->
storage
,
$key
,
$value
);
if
(
$this
->
sectionable
(
$key
))
}
{
list
(
$section
,
$key
)
=
$this
->
parse
(
$key
);
/**
return
$this
->
put_in_section
(
$section
,
$key
,
$value
,
$minutes
);
* Write a sectioned item to the cache.
}
*
else
* @param string $section
* @param string $key
* @param mixed $value
* @param int $minutes
* @return void
*/
public
function
put_in_section
(
$section
,
$key
,
$value
,
$minutes
)
{
{
$this
->
put
(
$this
->
section_item_key
(
$section
,
$key
),
$value
,
$minutes
);
array_set
(
$this
->
storage
,
$key
,
$value
);
}
}
}
/**
/**
...
@@ -86,73 +75,44 @@ class Memory extends Sectionable {
...
@@ -86,73 +75,44 @@ class Memory extends Sectionable {
* @return void
* @return void
*/
*/
public
function
forever
(
$key
,
$value
)
public
function
forever
(
$key
,
$value
)
{
if
(
$this
->
sectionable
(
$key
))
{
list
(
$section
,
$key
)
=
$this
->
parse
(
$key
);
return
$this
->
forever_in_section
(
$section
,
$key
,
$value
);
}
else
{
{
$this
->
put
(
$key
,
$value
,
0
);
$this
->
put
(
$key
,
$value
,
0
);
}
}
}
/**
/**
*
Write a sectioned item to the cache that lasts forever
.
*
Delete an item from the cache
.
*
*
* @param string $section
* @param string $key
* @param string $key
* @param mixed $value
* @return void
* @return void
*/
*/
public
function
for
ever_in_section
(
$section
,
$key
,
$value
)
public
function
for
get
(
$key
)
{
{
$this
->
put_in_section
(
$section
,
$key
,
$value
,
0
);
if
(
$this
->
sectionable
(
$key
))
}
/**
* Get a sectioned item from the cache, or cache and return the default value.
*
* @param string $section
* @param string $key
* @param mixed $default
* @param int $minutes
* @return mixed
*/
public
function
remember_in_section
(
$section
,
$key
,
$default
,
$minutes
,
$function
=
'put'
)
{
{
$key
=
$this
->
section_item_key
(
$section
,
$key
);
list
(
$section
,
$key
)
=
$this
->
parse
(
$key
);
return
$this
->
remember
(
$key
,
$default
,
$minutes
,
$function
);
if
(
$key
==
'*'
)
{
$this
->
forget_section
(
$section
);
}
}
else
/**
* Get a sectioned item from the cache, or cache the default value forever.
*
* @param string $section
* @param string $key
* @param mixed $default
* @return mixed
*/
public
function
sear_in_section
(
$section
,
$key
,
$default
)
{
{
return
$this
->
sear
(
$this
->
section_item_key
(
$section
,
$key
),
$default
);
$this
->
forget_in_section
(
$section
,
$key
);
}
}
}
/**
else
* Delete an item from the cache.
*
* @param string $key
* @return void
*/
public
function
forget
(
$key
)
{
{
array_forget
(
$this
->
storage
,
$key
);
array_forget
(
$this
->
storage
,
$key
);
}
}
/**
* Delete a sectioned item from the cache.
*
* @param string $section
* @param string $key
* @return void
*/
public
function
forget_in_section
(
$section
,
$key
)
{
$this
->
forget
(
$this
->
section_item_key
(
$section
,
$key
));
}
}
/**
/**
...
...
laravel/cache/drivers/sectionable.php
View file @
c49c6036
...
@@ -2,6 +2,20 @@
...
@@ -2,6 +2,20 @@
abstract
class
Sectionable
extends
Driver
{
abstract
class
Sectionable
extends
Driver
{
/**
* Indicates that section caching is implicit based on keys.
*
* @var bool
*/
public
$implicit
=
true
;
/**
* The implicit section key delimiter.
*
* @var string
*/
public
$delimiter
=
'::'
;
/**
/**
* Retrieve a sectioned item from the cache driver.
* Retrieve a sectioned item from the cache driver.
*
*
...
@@ -10,7 +24,10 @@ abstract class Sectionable extends Driver {
...
@@ -10,7 +24,10 @@ abstract class Sectionable extends Driver {
* @param mixed $default
* @param mixed $default
* @return mixed
* @return mixed
*/
*/
abstract
public
function
get_from_section
(
$section
,
$key
,
$default
=
null
);
public
function
get_from_section
(
$section
,
$key
,
$default
=
null
)
{
return
$this
->
get
(
$this
->
section_item_key
(
$section
,
$key
),
$default
);
}
/**
/**
* Write a sectioned item to the cache.
* Write a sectioned item to the cache.
...
@@ -21,7 +38,10 @@ abstract class Sectionable extends Driver {
...
@@ -21,7 +38,10 @@ abstract class Sectionable extends Driver {
* @param int $minutes
* @param int $minutes
* @return void
* @return void
*/
*/
abstract
public
function
put_in_section
(
$section
,
$key
,
$value
,
$minutes
);
public
function
put_in_section
(
$section
,
$key
,
$value
,
$minutes
)
{
$this
->
put
(
$this
->
section_item_key
(
$section
,
$key
),
$value
,
$minutes
);
}
/**
/**
* Write a sectioned item to the cache that lasts forever.
* Write a sectioned item to the cache that lasts forever.
...
@@ -31,7 +51,10 @@ abstract class Sectionable extends Driver {
...
@@ -31,7 +51,10 @@ abstract class Sectionable extends Driver {
* @param mixed $value
* @param mixed $value
* @return void
* @return void
*/
*/
abstract
public
function
forever_in_section
(
$section
,
$key
,
$value
);
public
function
forever_in_section
(
$section
,
$key
,
$value
)
{
return
$this
->
forever
(
$this
->
section_item_key
(
$section
,
$key
),
$value
);
}
/**
/**
* Get a sectioned item from the cache, or cache and return the default value.
* Get a sectioned item from the cache, or cache and return the default value.
...
@@ -42,7 +65,12 @@ abstract class Sectionable extends Driver {
...
@@ -42,7 +65,12 @@ abstract class Sectionable extends Driver {
* @param int $minutes
* @param int $minutes
* @return mixed
* @return mixed
*/
*/
abstract
public
function
remember_in_section
(
$section
,
$key
,
$default
,
$minutes
,
$function
=
'put'
);
public
function
remember_in_section
(
$section
,
$key
,
$default
,
$minutes
,
$function
=
'put'
)
{
$key
=
$this
->
section_item_key
(
$section
,
$key
);
return
$this
->
remember
(
$key
,
$default
,
$minutes
,
$function
);
}
/**
/**
* Get a sectioned item from the cache, or cache the default value forever.
* Get a sectioned item from the cache, or cache the default value forever.
...
@@ -52,7 +80,10 @@ abstract class Sectionable extends Driver {
...
@@ -52,7 +80,10 @@ abstract class Sectionable extends Driver {
* @param mixed $default
* @param mixed $default
* @return mixed
* @return mixed
*/
*/
abstract
public
function
sear_in_section
(
$section
,
$key
,
$default
);
public
function
sear_in_section
(
$section
,
$key
,
$default
)
{
return
$this
->
sear
(
$this
->
section_item_key
(
$section
,
$key
),
$default
);
}
/**
/**
* Delete a sectioned item from the cache.
* Delete a sectioned item from the cache.
...
@@ -61,7 +92,10 @@ abstract class Sectionable extends Driver {
...
@@ -61,7 +92,10 @@ abstract class Sectionable extends Driver {
* @param string $key
* @param string $key
* @return void
* @return void
*/
*/
abstract
public
function
forget_in_section
(
$section
,
$key
);
public
function
forget_in_section
(
$section
,
$key
)
{
return
$this
->
forget
(
$this
->
section_item_key
(
$section
,
$key
));
}
/**
/**
* Delete an entire section from the cache.
* Delete an entire section from the cache.
...
...
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