UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'DiPUWi7c+axmEGq0i6KUyD5S9XrioKQUaNpfpoej9rI=' 
WHERE 
  key_id = 'caab952b138189ec886c8fed317381e77b67e7c30c36b6e73c4dc58f36904338' 
  AND (
    token = 'DiPUWi7c+axmEGq0i6KUyD5S9XrioKQUaNpfpoej9rI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034