#1008 中美企业服务差异
市场 2024-02-04《创业 7 年复盘,中美企业服务市场差异浅析》阅读笔记:
| 美国 | 中国 |
|---|---|
| 标准 + 专业分工 + 集成整合 | 大而全,啥都做 |
| AI 应用创新相对丰富 | 相对落后 |
| 管理标准化 | 相对落后 |
| 订阅 | 买断 |
| 云 | Self-hosted |
| SaaS 服务 | 自研 |
| 强调 UX | 功能 |
客户、人才、基础建设有关。
coding in a complicated world
《创业 7 年复盘,中美企业服务市场差异浅析》阅读笔记:
| 美国 | 中国 |
|---|---|
| 标准 + 专业分工 + 集成整合 | 大而全,啥都做 |
| AI 应用创新相对丰富 | 相对落后 |
| 管理标准化 | 相对落后 |
| 订阅 | 买断 |
| 云 | Self-hosted |
| SaaS 服务 | 自研 |
| 强调 UX | 功能 |
客户、人才、基础建设有关。
最新一期《开发者周刊》上有一个言论击中我了:
有一个名词叫做"报复性熬夜",指的是有些人明明在白天疲劳不堪,晚上却不愿意早睡,宁愿在床上玩手机。
这是因为他们控制不了自己的生活,通过在晚上推迟睡觉,获得一点自己掌控时间的自由感。
-- 《报复性熬夜》
我也一直持差不多的观点,白天太多事了,工作的、家庭的,这些时间并不属于我自己,直到晚上、半夜,一片寂静中,才有片刻时间真正可以自由支配。
坐在沙发上,坐在马桶上,抑或躺在床上,刷刷抖音,打打代码。
百度百科对熬夜是这样定义的:
熬夜,汉语词语,意为深夜还不睡。泛指因事通宵或至深夜忍困不眠。出自《清平山堂话本·快嘴李翠莲记》。
熬夜是一种现代生活经常听到或者做到的一种现象,是一种危害人的身体的不良习惯,可导致一些疾病,降低效率。熬夜是不良习惯的一种,容易缺乏内源氧。
报复性熬夜,原文中讲的都是一些老生常谈的内容,伤害身体之类,只有 “获得一点自己掌控时间的自由感” 这一句话表达得非常精彩,比我之前的表达更准确。
熬夜自然是伤身体的,这每个人都知道。
挤出来的这点时间感觉才是真正的休息,从各种角色中抽身出来,做做自己。
难以抵抗这片刻自由的诱惑啊!
公众号 Python 集中营发了一篇文章《盘点即将消失的五种编程语言!》,介绍了 Ruby、VB、Perl、Delphi、Haskell 这 5 种语言。
消失不消失我不知道,这里对这几种语言做个简单了解。
后期优化:
package main
import (
"fmt"
"sync"
"time"
)
type CacheItem struct {
key string
value interface{}
expiration time.Time
}
type Cache struct {
items map[string]CacheItem // 缓存项
mu sync.Mutex // 锁保护并发读写
cleanupInterval time.Duration // 清理缓存的时间间隔
}
// 创建一个新的缓存实例
func NewCache(cleanupInterval time.Duration) *Cache {
c := &Cache{
items: make(map[string]CacheItem),
cleanupInterval: cleanupInterval,
}
// 启动后台清理任务
go c.startCleanup()
return c
}
// 启动后台定期清理过期缓存的任务
func (c *Cache) startCleanup() {
ticker := time.NewTicker(c.cleanupInterval)
for {
<-ticker.C
c.cleanUpExpiredItems()
}
}
// 清理过期缓存项
func (c *Cache) cleanUpExpiredItems() {
c.mu.Lock()
defer c.mu.Unlock()
// 清理有过期时间的缓存项
for key, item := range c.items {
if time.Now().After(item.expiration) {
delete(c.items, key)
}
}
// 打印清理日志(可以根据需要调整)
fmt.Println("Expired cache items cleaned up")
}
// 添加缓存项,支持过期时间
func (c *Cache) Set(key string, value interface{}, expiration time.Time) {
c.mu.Lock()
defer c.mu.Unlock()
c.items[key] = CacheItem{key: key, value: value, expiration: expiration}
}
// 获取缓存项
func (c *Cache) Get(key string) (interface{}, bool) {
c.mu.Lock()
defer c.mu.Unlock()
// 再检查有过期时间的缓存项
if item, found := c.items[key]; found {
// if item.expiration.IsZero() || time.Now().Before(item.expiration) {
// return item.value, true
// }
// // 如果缓存项已过期,则删除并返回未找到
// delete(c.items, key)
return item.value, true
}
return nil, false
}
// 删除缓存项
func (c *Cache) Delete(key string) {
c.mu.Lock()
defer c.mu.Unlock()
delete(c.items, key)
}
func main() {
// 创建一个缓存实例,每 1 秒清理一次过期缓存
cache := NewCache(1 * time.Second)
// 设置缓存项(带过期时间)
cache.Set("key1", "value1", time.Now().Add(5*time.Second))
// 设置没有过期时间的缓存项
cache.Set("key2", "value2", time.Time{}) // 空时间表示永不过期
// 获取缓存项
if value, found := cache.Get("key1"); found {
fmt.Println("Found key1:", value)
} else {
fmt.Println("key1 not found")
}
if value, found := cache.Get("key2"); found {
fmt.Println("Found key2:", value)
} else {
fmt.Println("key2 not found")
}
// 等待 6 秒后,key1 会过期
time.Sleep(6 * time.Second)
// 再次获取缓存项
if value, found := cache.Get("key1"); found {
fmt.Println("Found key1:", value)
} else {
fmt.Println("key1 not found (after expiration)")
}
if value, found := cache.Get("key2"); found {
fmt.Println("Found key2:", value)
} else {
fmt.Println("key2 not found")
}
// 让清理任务继续运行
select {}
}