{"id":291109,"date":"2018-10-21T10:40:02","date_gmt":"2018-10-21T06:40:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=291109"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2018-10-21T06:40:02","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=291109","title":{"rendered":"\u041a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 Java Spring"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u041c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0432\u044b\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0432\u0441\u0442\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0438\u043b\u0438 \u0440\u0435\u0434\u043a\u043e \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u044d\u0442\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0438 \u0438 \u0434\u0440. \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0442.\u0435. \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 \u2014 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0430. \u0422\u0443\u0442 \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u0432\u0441\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 \u2014 \u043d\u0443\u0436\u0435\u043d \u041a\u0435\u0448! \u0417\u0430\u0447\u0435\u043c \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435? <br \/>  \u0422\u0430\u043a \u0432\u043e\u0442 \u0437\u0434\u0435\u0441\u044c \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0435\u0448 \u0432 Java Spring \u0438 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u0442\u0435\u0441\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0441 \u0411\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u0438 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u0421\u0423\u0411\u0414 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439.<br \/>  <b>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435  <\/p>\n<ul>\n<li>\u041a\u0435\u0448 \u0432 Spring<\/li>\n<li>\u041a\u0435\u0448 \u0432 Oracle PL-SQL \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <\/li>\n<\/ul>\n<p>  <a name=\"habracut\"><\/a><\/b>  <\/p>\n<h3>\u041a\u0435\u0448 \u0432 Spring<\/h3>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0432\u0441\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e, \u0432 Java \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 HasMap, ConcurrentMap \u0438 \u0434\u0440. \u0412 Spring \u0442\u043e\u0436\u0435 \u0434\u043b\u044f \u044d\u0442\u043e \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u0443\u0434\u043e\u0431\u043d\u043e\u0435, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435. \u042f \u0434\u0443\u043c\u0430\u044e \u0447\u0442\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u044d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438. \u0418 \u0442\u0430\u043a, \u0432\u0441\u0435 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u044d\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u0435\u0448 \u0438 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<br \/>  \u0414\u0435\u043b\u0430\u0435\u043c \u043a\u0435\u0448 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c  <\/p>\n<pre><code class=\"java\">@SpringBootApplication @EnableCaching public class DemoCacheAbleApplication {  \tpublic static void main(String[] args) { \t\tSpringApplication.run(DemoCacheAbleApplication.class, args); \t} } <\/code><\/pre>\n<p>  \u041a\u0435\u0448\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438  <\/p>\n<pre><code class=\"java\">    @Cacheable(cacheNames=\"person\")     public Person findCacheByName(String name) {   \/\/... } <\/code><\/pre>\n<p>  \u0412 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u0435\u0448\u0430 \u0438 \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a, \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u0435\u0448 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 name) \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043a\u043e\u0434 \u0443\u0436\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043a\u0435\u0448\u0430.<br \/>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u00abPerson\u00bb \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u0435\u0448\u0430  <\/p>\n<pre><code class=\"java\">@Component public class PersonRepository {      private static final Logger logger = LoggerFactory.getLogger(PersonRepository.class);     private List&lt;Person&gt; persons  = new ArrayList&lt;&gt;();      public void initPersons(List&lt;Person&gt; persons) {        this.persons.addAll(persons);     }      private Person findByName(String name) {         Person person = persons.stream()                 .filter(p -&gt; p.getName().equals(name))                 .findFirst()                 .orElse(null);         return person;     }      @Cacheable(cacheNames=\"person\")     public Person findCacheByName(String name) {         logger.info(\"find person ... \" + name);         final Person person = findByName(name);         return person;     } } <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c  <\/p>\n<pre><code class=\"java\">@RunWith(SpringRunner.class) @SpringBootTest public class DemoCacheAbleApplicationTests {   \tprivate static final Logger logger = LoggerFactory.getLogger(DemoCacheAbleApplicationTests.class);  \t@Autowired \tprivate PersonRepository personRepository;  \t@Before \tpublic void before() { \t\tpersonRepository.initPersons(Arrays.asList(new Person(\"\u0418\u0432\u0430\u043d\", 22), \t\t\t\tnew Person(\"\u0421\u0435\u0440\u0433\u0435\u0439\", 34), \t\t\t\tnew Person(\"\u0418\u0433\u043e\u0440\u044c\", 41))); \t}   \tprivate Person findCacheByName(String name) {         logger.info(\"begin find \" + name);         final Person person = personRepository.findCacheByName(name);         logger.info(\"find result = \" + person.toString());         return person;     }  \t@Test \tpublic void findByName() { \t\tfindCacheByName(\"\u0418\u0432\u0430\u043d\"); \t\tfindCacheByName(\"\u0418\u0432\u0430\u043d\"); \t} } <\/code><\/pre>\n<p>  \u0412 \u0442\u0435\u0441\u0442\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e \u0434\u0432\u0430 \u0440\u0430\u0437\u0430   <\/p>\n<pre><code class=\"java\">@Test public void findByName() { \t  findCacheByName(\"\u0418\u0432\u0430\u043d\"); \t  findCacheByName(\"\u0418\u0432\u0430\u043d\"); } <\/code><\/pre>\n<p>, \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0437\u043e\u0432, \u043f\u043e\u0438\u0441\u043a, \u0432 \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0438\u0437 \u043a\u0435\u0448\u0430. \u042d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 <br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fv\/oa\/fj\/fvoafj02zaxlf18p4cmdg_i1ad0.png\" alt=\"image\"> <br \/>  \u0423\u0434\u043e\u0431\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u0447\u0435\u0447\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b. \u0415\u0441\u043b\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043c\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u043a\u0430\u043a\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430.   <\/p>\n<pre><code class=\"java\">    @Cacheable(cacheNames=\"person\", key=\"#name\")     public Person findByKeyField(String name, Integer age) { <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u044c \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0441\u0445\u0435\u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430, \u044d\u0442\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<br \/>  \u041d\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0432\u0441\u0442\u0430\u043d\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u0430\u043a \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u0435\u0448\u0435? \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438.<br \/>  \u041f\u0435\u0440\u0432\u0430\u044f \u044d\u0442\u043e <code>@CachePut<\/code> <br \/>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441 \u044d\u0442\u043e\u0439 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \u043a\u0435\u0448, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u043d\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u0435\u0448.<br \/>  \u0414\u043e\u0431\u0430\u0432\u043b\u044e \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430: \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f Person   <\/p>\n<pre><code class=\"java\">    public boolean delete(String name) {         final Person person = findByName(name);         return persons.remove(person);     }      public boolean add(Person person) {        return persons.add(person);     } <\/code><\/pre>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u044e \u043f\u043e\u0438\u0441\u043a Person, \u0443\u0434\u0430\u043b\u044e, \u0434\u043e\u0431\u0430\u0432\u043b\u044e, \u043e\u043f\u044f\u0442\u044c \u043f\u043e\u0438\u0441\u043a, \u043d\u043e \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0431\u0443\u0434\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435 \u043b\u0438\u0446\u043e \u0438\u0437 \u043a\u0435\u0448\u0430, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0443 \u00abfindByNameAndPut\u00bb  <\/p>\n<pre><code class=\"java\">    @CachePut(cacheNames=\"person\")     public Person findByNameAndPut(String name) {         logger.info(\"findByName and put person ... \" + name);         final Person person = findByName(name);         logger.info(\"put in cache person \" + person);         return person;     } <\/code><\/pre>\n<p>  \u0422\u0435\u0441\u0442  <\/p>\n<pre><code class=\"java\">\t@Test \tpublic void findCacheByNameAndPut() {         Person person = findCacheByName(\"\u0418\u0432\u0430\u043d\");  \t\tlogger.info(\"delete \" + person); \t\tpersonRepository.delete(\"\u0418\u0432\u0430\u043d\");          findCacheByName(\"\u0418\u0432\u0430\u043d\");  \t\tlogger.info(\"add new person\"); \t\tperson = new Person(\"\u0418\u0432\u0430\u043d\", 35); \t\tpersonRepository.add(person);          findCacheByName(\"\u0418\u0432\u0430\u043d\");  \t\tlogger.info(\"put new\"); \t\tpersonRepository.findByNameAndPut(\"\u0418\u0432\u0430\u043d\");          findCacheByName(\"\u0418\u0432\u0430\u043d\"); \t} <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uk\/so\/sw\/uksoswybivefc08c5ai9isattfs.png\" alt=\"image\"><\/p>\n<p>  \u0414\u0440\u0443\u0433\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u044d\u0442\u043e <code>@CacheEvict <\/code><br \/>  \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u0435\u0449\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043a\u0435\u0448\u0430, \u043d\u043e \u0438 \u0432\u044b\u0441\u0435\u043b\u044f\u0442\u044c. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445 \u0438\u043b\u0438 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043a\u0435\u0448\u0430.<\/p>\n<p>  \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Spring \u0434\u043b\u044f \u043a\u0435\u0448\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u2014 ConcurrentMapCache, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0435\u0448\u0430, \u0442\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 CacheManager   <\/p>\n<pre><code class=\"java\">@SpringBootApplication @EnableCaching public class DemoCacheAbleApplication {  \tpublic static void main(String[] args) { \t\tSpringApplication.run(DemoCacheAbleApplication.class, args); \t}  \t@Bean \tpublic CacheManager cacheManager() { \t\tSimpleCacheManager cacheManager = new SimpleCacheManager(); \t\tcacheManager.setCaches(Arrays.asList( \t\t\t\tnew ConcurrentMapCache(\"person\"), \t\t\t\tnew ConcurrentMapCache(\"addresses\"))); \t\treturn cacheManager; \t} } <\/code><\/pre>\n<p>  \u0422\u0430\u043c \u0436\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u0430 \u043a\u0435\u0448\u0435\u0439, \u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e. \u0412 xml \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Spring configuration.xml<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"        xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"        xmlns:cache=\"http:\/\/www.springframework.org\/schema\/cache\"        xsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/beans         http:\/\/www.springframework.org\/schema\/beans\/spring-beans.xsd         http:\/\/www.springframework.org\/schema\/cache http:\/\/www.springframework.org\/schema\/cache\/spring-cache.xsd\"&gt;      &lt;cache:annotation-driven\/&gt;      &lt;bean id=\"cacheManager\"           class=\"org.springframework.cache.support.SimpleCacheManager\"&gt;         &lt;property name=\"caches\"&gt;             &lt;set&gt;                 &lt;bean                         class=\"org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean\"                         name=\"person\"\/&gt;                 &lt;bean                         class=\"org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean\"                         name=\"addresses\"\/&gt;             &lt;\/set&gt;         &lt;\/property&gt;     &lt;\/bean&gt;  &lt;\/beans&gt;<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Person \u043a\u043b\u0430\u0441\u0441<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">public class Person {      private String name;     private Integer age;      public Person(String name, Integer age) {         this.name = name;         this.age = age;     }      public String getName() {         return name;     }      public Integer getAge() {         return age;     }      @Override     public String toString() {         return name + \":\" + age;     }  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/3d\/xw\/t5\/3dxwt5scumx16ymje6dqhbn0utk.png\" alt=\"image\"><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0434\u0435\u0441\u044c pom.xml<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" \txsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt; \t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;  \t&lt;groupId&gt;com.example&lt;\/groupId&gt; \t&lt;artifactId&gt;demoCacheAble&lt;\/artifactId&gt; \t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt; \t&lt;packaging&gt;jar&lt;\/packaging&gt;  \t&lt;name&gt;DemoCacheAble&lt;\/name&gt; \t&lt;description&gt;Demo project for Spring Boot&lt;\/description&gt;  \t&lt;parent&gt; \t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; \t\t&lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt; \t\t&lt;version&gt;2.0.6.RELEASE&lt;\/version&gt; \t\t&lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt; \t&lt;\/parent&gt;  \t&lt;properties&gt; \t\t&lt;project.build.sourceEncoding&gt;UTF-8&lt;\/project.build.sourceEncoding&gt; \t\t&lt;project.reporting.outputEncoding&gt;UTF-8&lt;\/project.reporting.outputEncoding&gt; \t\t&lt;java.version&gt;1.8&lt;\/java.version&gt; \t&lt;\/properties&gt;  \t&lt;dependencies&gt; \t\t&lt;dependency&gt; \t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; \t\t\t&lt;artifactId&gt;spring-boot-starter-cache&lt;\/artifactId&gt; \t\t&lt;\/dependency&gt;  \t\t&lt;dependency&gt; \t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; \t\t\t&lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt; \t\t\t&lt;scope&gt;test&lt;\/scope&gt; \t\t&lt;\/dependency&gt; \t&lt;\/dependencies&gt;  \t&lt;build&gt; \t\t&lt;plugins&gt; \t\t\t&lt;plugin&gt; \t\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; \t\t\t\t&lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt; \t\t\t&lt;\/plugin&gt; \t\t&lt;\/plugins&gt; \t&lt;\/build&gt; &lt;\/project&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u041a\u0435\u0448 \u0432 Oracle PL-SQL \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h3>\n<p>  \u041d\u0443 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435, \u0442\u0435\u043c \u043a\u0442\u043e \u043d\u0435 \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0433\u0430\u0435\u0442 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c\u044e \u0421\u0423\u0411\u0414, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0435\u0435, \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0411\u0414, \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043a\u0430\u043a \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443. \u0422\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 Oracle \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043a \u043d\u0435\u0439 <\/p>\n<blockquote><p>RESULT_CACHE<\/p><\/blockquote>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code class=\"sql\">CREATE OR REPLACE FUNCTION GET_COUNTRY_NAME(P_CODE IN VARCHAR2)   RETURN VARCHAR2 RESULT_CACHE IS   CODE_RESULT VARCHAR2(50); BEGIN   SELECT COUNTRY_NAME INTO CODE_RESULT FROM COUNTRIES   WHERE COUNTRY_ID = P_CODE;   -- \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0433\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b   dbms_lock.sleep (1);       RETURN(CODE_RESULT); END;  <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043a\u0435\u0448 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0435\u043d, \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043d\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043a\u0435\u0448\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <\/p>\n<blockquote><p>RELIES_ON(&#8230;)<\/p><\/blockquote>\n<p>  \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b<br \/>  <a href=\"https:\/\/docs.spring.io\/spring\/docs\/current\/spring-framework-reference\/integration.html#cache\">Cache Abstraction<\/a><\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/post\/427187\/\"> https:\/\/habr.com\/post\/427187\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u041c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0432\u044b\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0432\u0441\u0442\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0438\u043b\u0438 \u0440\u0435\u0434\u043a\u043e \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u044d\u0442\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0438 \u0438 \u0434\u0440. \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0442.\u0435. \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 \u2014 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0430. \u0422\u0443\u0442 \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u0432\u0441\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 \u2014 \u043d\u0443\u0436\u0435\u043d \u041a\u0435\u0448! \u0417\u0430\u0447\u0435\u043c \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435? <br \/>  \u0422\u0430\u043a \u0432\u043e\u0442 \u0437\u0434\u0435\u0441\u044c \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0435\u0448 \u0432 Java Spring \u0438 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u0442\u0435\u0441\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0441 \u0411\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u0438 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u0421\u0423\u0411\u0414 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439.<br \/>  <b>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435  <\/p>\n<ul>\n<li>\u041a\u0435\u0448 \u0432 Spring<\/li>\n<li>\u041a\u0435\u0448 \u0432 Oracle PL-SQL \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <\/li>\n<\/ul>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-291109","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=291109"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/291109\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=291109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=291109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=291109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}