UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ozAX+eHlG5//yztw61589xzsprJccDvJIYuQ+i6BTAI=' 
WHERE 
  key_id = '12bef256dab082a2ff91e8634bee59d360a05e55feb4ef2298e90c980507483a' 
  AND (
    token = 'ozAX+eHlG5//yztw61589xzsprJccDvJIYuQ+i6BTAI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00044