UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'J+2P2f+KwGch+yoyPK+tPUS8lh/Qkf6oiNv6YNHV+mc=' 
WHERE 
  key_id = '0cf9936e378a88d9ccfdc2d09837e76473aeb8c9123de673b88d63ce735d87a0' 
  AND (
    token = 'J+2P2f+KwGch+yoyPK+tPUS8lh/Qkf6oiNv6YNHV+mc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032