UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'DyiGG9uYZnBuE1h+gxa3UvvRKTWZjeKgUoISelmWQ+Q=' 
WHERE 
  key_id = 'e1a1c5c5617e9046661c97b60a1cef7d122ec58926abbd0038ff33dddcec6db4' 
  AND (
    token = 'DyiGG9uYZnBuE1h+gxa3UvvRKTWZjeKgUoISelmWQ+Q=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00023